【问题标题】:Prevent Apache to cache html5 manifest阻止 Apache 缓存 html5 清单
【发布时间】:2014-10-26 22:47:41
【问题描述】:

这可能真的很容易解决,我检查过stackoverflow但我没有找到任何东西:

我已经用 PHP 和 Apache 安装了 WAMP,成功运行最新版本的 Laravel。

我有一个 cache.manifest 文件,它可以正确加载,但是即使我更改了它的内容,它似乎也不会刷新。

所以我尝试了一些我发现的东西,包括:

AddType text/cache-manifest .manifest
<IfModule mod_rewrite.c>
   Options -MultiViews
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^ index.php [L]
</IfModule>
<FilesMatch "\.manifest$">
   Header set Cache-Control "max-age=259200, proxy-revalidate"
</FilesMatch>

当我添加 FilesMatch 部分时,我总是收到 Internal Server Error

我能做些什么来防止只缓存 cache.manifest 文件? 我也尝试过使用 FileMatch 进行其他操作,但每次都失败(例如,我有那种图像代码(png gif ...),但它不起作用。

感谢您的帮助。

【问题讨论】:

    标签: html caching


    【解决方案1】:

    按类型使用过期时间

    AddType 语句已经存在,以确保清单文件具有正确的 mime 类型。这可用于指定适当的缓存头:

    ExpiresByType text/cache-manifest "access plus 0 seconds"
    

    html5 boilerplate htaccess file 中提供了这些以及更多有用的信息。

    【讨论】:

      【解决方案2】:

      另一种解决方案是使用PHP,因为根据HTML5 specification cache-manifest 文件的扩展名无关紧要:

      <?php
      header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
      header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
      header('Content-Type: text/cache-manifest');
      //your content below out of PHP tag
      ?>
      CACHE MANIFEST
      

      那么你可以使用:

      <html manifest="manifest.php">
      

      【讨论】:

      • 谢谢,我理解你的意思,我认为应该可以,但我更喜欢直接在 Apache 中设置。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-20
      • 1970-01-01
      • 2010-09-21
      • 2011-01-04
      • 2016-07-04
      • 2011-11-27
      • 1970-01-01
      相关资源
      最近更新 更多