静态化方法包括:
生成方式
抓取方式
伪静态化
混合方式
静态化可以改善SEO
主要由程序实现
例如
content = "<html><title>my static</title><body>hello world</body></html>" file = open( your static file) file.write(content) file.close()
主要由程序实现
程序中抓取
content = get_url('http://netkiller.8800.org/index.php')
file = open( index.html)
file.write(content)
file.close()
使用软件抓取,不仅限于wget。
wget http://netkiller.8800.org/index.php -O index.html
这时只给出简单例子,使用复杂参数实现更复杂的拾取,然后将脚本加入crontab中可。
伪静态化是主要是通过在URL上做一些手脚,使你看去是静态的,实质上它是动态脚本。
伪静态化实现主要包括两种方法:
Rewrite rule
path_info
下面是一个PATH_INFO例子
http://netkiller.8800.org/zh-cn/photography/browse/2009.html
根本就不存在这个目录'zh-cn/photography/browse/'和文件'2009.html'
下面是一个Rewrite例子
http://example.org/bbs/thread-1003872-1-1.html
其实目前网站使用的基本上都是上面几种方法混合方式。
例如首先将动态url(example.org/news.php?cid=1&id=1) 通过rewrite转换为 (example.org/new_1_1.html)
接下来就比较容易解决了,一种方法是使用wget example.org/new_1_1.html,另一种方法你无需静态化,直接使用squid规则配置让他永不过期