利用浏览器缓存

osh*_*nen 16 html php browser caching browser-cache

根据:http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching我应该使用浏览器缓存.但是,我不知道怎么做.

我只是在html部分添加某些标签吗?或者是我需要通过服务器发送给客户端的东西?与php标题有关吗?

Que*_*tin 14

缓存由各种HTTP标头控制.您应该阅读Mark Nottingham的Web作者和网站管理员缓存教程.您可以使用标头功能为从PHP输出的文档设置HTTP标.


Rik*_*esh 8

您可以在.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 ##
Run Code Online (Sandbox Code Playgroud)