【问题标题】:cache control not working properly缓存控制无法正常工作
【发布时间】:2012-07-15 07:26:54
【问题描述】:

我在 .htaccess 文件中放置了一个简单的缓存控件:

#cache css and javascript files for one week  
<FilesMatch ".(js|css)$">  
Header set Cache-Control "max-age=604800"  
</FilesMatch>

当我在 Google 的页面站点测试器上测试桌面站点时:https://developers.google.com/speed/pagespeed/insights ... 它显示 javascript 和图像正在被正确缓存。但是,当我测试我的移动网站时,缓存不起作用。我的 htaccess 文件与我的所有桌面文件(即 public_html/index.html、public_html/images/、public_html/css/、public_html/.htaccess 等)一起包含在 public_html 目录中。我的移动站点包含在此处:public_html/mobile /.

是否需要将第二个 .htaccess 文件添加到移动目录才能使其正常工作?

谢谢。

【问题讨论】:

    标签: .htaccess caching


    【解决方案1】:

    最好的选择是使用 html5 样板的 .htaccess 文件。它针对缓存、gzip、跨域ajax以及许多功能进行了高度优化。

    还要检查 mod_deflate 是否打开。

    您不需要任何额外的 .htaccess 文件,只需使用目录根目录中的单个文件即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 2019-11-24
      • 2019-09-01
      • 2013-03-04
      • 1970-01-01
      相关资源
      最近更新 更多