Reputation: 3971
I work on SAP app. On the client I use angularjs, and my code is devided into html (template) files, and javascript files.
My server is Apache.
When I upload javascript files, browser cache often successfully update the files, and I don't need to clear browser cache.
However, when I upload new versions of html template files, browsers don't usually update cached versions, (I use chrome, and firefox, on Windows 8, and Mac)
I get used to clear cache and ask everybody in the team (and the client) to clear cache whenever I update my template files.
Is this the regular browser cache behavior?
Is it normal that browsers tend to cache html template files more than it does on javascript files?
Is there an Apache config that helps making browser be more sensitive to newer versions of html files?
thank you
Upvotes: 2
Views: 2580
Reputation: 1923
The meta tags are not strong. The OP is right to ask for Apache directives. Here is a working solution: How to prevent http file caching in Apache httpd (MAMP)
The solution, which can be put in .htaccess
, httpd.conf
and in a VirtualHost
:
<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
Credit @ Charlie Rudenstal https://stackoverflow.com/users/1552414/charlie-rudenst%C3%A5l
Here is a short comparison of response HTTP Headers and HTML Meta Tags http://condor.depaul.edu/dmumaugh/readings/handouts/SE435/HTTP/node20.html, quote:
(Meta Tags) are usually honored by browser caches (which actually read the HTML), not proxy caches (which almost never read the HTML markup in the document).
Upvotes: 3
Reputation: 1994
You can use the following meta tag in your HTML files:
<meta http-equiv="cache-control" content="no-cache, no-store">
To maintain backwards compatibility with HTTP/1.0 also include the following:
<meta http-equiv="pragma" content="no-cache">
Upvotes: 1