根据http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching的说法,我应该使用浏览器缓存。但是,我不知道怎么做。
我是否简单地将某些标记添加到html部分?或者是我需要通过服务器发送到客户端的东西?和php头有什么关系?
发布于 2011-04-08 21:33:20
缓存是通过各种HTTP标头控制的。你应该读一读马克·诺丁汉的Caching Tutorial for Web Authors and Webmasters。您可以使用header函数为从PHP输出的文档设置headers。
发布于 2011-04-08 21:35:23
你可以在你的.htaccess中做这样的事情。
## EXPIRES CACHING ##
<IfModule mod_expires>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##https://stackoverflow.com/questions/5595790
复制相似问题