阻止Apache缓存html5清单

时间:2013-07-22 21:15:48

标签: html5 caching

这可能很容易解决,我已经检查了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部分时,我总是得到内部服务器错误

我该怎么做才能阻止缓存cache.manifest文件? 我也尝试过使用FileMatch的其他东西但是它每次都失败了(例如我有那种图像代码(png gif ...)并且它不起作用。

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

按类型使用过期

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

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

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

答案 1 :(得分:1)

另一种解决方案是使用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">
相关问题