我在MAMP中开发单页Javascript应用程序。我的JavaScript和HTML模板文件在请求之间被缓存。
I am developing a single page Javascript application in MAMP. My JavaScript and HTML template files are getting cached between requests.
是否有一种简单的方法在MAMP中指示我想阻止http文件缓存?可能有一个 .htaccess 文件?我在哪里放置 .htaccess 或在Mac上修改MAMP的虚拟主机?
Is there a simple way to indicate in MAMP that I want to prevent http file caching? Possibly with a .htaccess file? Where do I place the .htaccess or modify the virtual host for MAMP on Mac?
推荐答案试过这个?应该在 .htaccess , httpd.conf 以及 VirtualHost (通常放在 httpd-vhosts.conf ,如果你已经从你的httpd.conf中包含它)
Tried this? Should work in both .htaccess, httpd.conf and in a VirtualHost (usually placed in httpd-vhosts.conf if you have included it from your httpd.conf)
<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>
100%防止文件被缓存
100% Prevent Files from being cached
这类似于Google广告如何使用标头Cache-Control:private,x-gzip-ok =>来阻止代理和客户端对广告进行缓存。
This is similar to how google ads employ the header Cache-Control: private, x-gzip-ok="" > to prevent caching of ads by proxies and clients.
来自 www.askapache/htaccess/using-http-headers-with-htaccess.html
并可选择添加扩展名如果您使用 .html 以外的扩展程序,那么您要检索的模板文件。
And optionally add the extension for the template files you are retrieving if you are using an extension other than .html for those.
更多推荐
如何防止Apache httpd(MAMP)中的http文件缓存
发布评论