根据:http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching我应该使用浏览器缓存。但是,我不知道如何。利用浏览器缓存
我是否只需将某些标签添加到html部分?或者是我需要通过服务器发送给客户端的东西?一些与PHP头文件?
根据:http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching我应该使用浏览器缓存。但是,我不知道如何。利用浏览器缓存
我是否只需将某些标签添加到html部分?或者是我需要通过服务器发送给客户端的东西?一些与PHP头文件?
缓存通过各种HTTP头进行控制。你应该读马克诺丁汉的Caching Tutorial for Web Authors and Webmasters。您可以使用header函数为从PHP输出的文档设置HTTP标头。
你可以在你的.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 ##
这没有什么区别?我正在与pingdom.com检查其他建议吗? – alex 2014-02-19 15:50:12
@Rikesh:上面的代码是从哪里引用的,还是你自己的代码?我原来虽然是从Ashraf Malik的回答那里复制/粘贴的,但我现在看到你的名字早在几年前就已发布。 Ashraf抄袭了你的代码吗? – 2016-07-04 19:27:06