Prevent Apache html5 manifest caching

This is probably very easy to solve, I checked stackoverflow but didn't find anything:

I have WAMP installed with PHP and Apache, successfully completing the latest version of Laravel.

I have a cache.manifest file, it loads correctly, but it does not update, even if I change its contents.

So, I tried several things that I found, including:

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> 

When I add the FilesMatch section, I always get an Internal Server Error

What can I do to prevent caching of the cache.manifest file only? I also tried other things with FileMatch, but it fails every time (for example, I had such code for images (png gif ...) and it did not work.

Thank you for your help.

+4
source share
2 answers

Use expiration type

The AddType statement is already present to ensure that the manifest files are of the correct mime type. This can be used to indicate the appropriate cache headers:

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

This and more useful information is available in the html5 htaccess template file .

+1
source

Another solution is to use PHP, because according to the HTML5 specification, the cache manifest file extension does not matter:

 <?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 

Then you can use:

 <html manifest="manifest.php"> 
+1
source

Source: https://habr.com/ru/post/1492795/


All Articles