apache - 如何防止 Apache httpd (MAMP) 中的 http 文件缓存

标签 apache .htaccess http-headers mamp

我正在 MAMP 中开发一个单页 Javascript 应用程序。我的 JavaScript 和 HTML 模板文件在请求之间被缓存。

是否有一种简单的方法可以在 MAMP 中指示我想要阻止 http 文件缓存?可能带有 .htaccess 文件?在 Mac 上,我应该在哪里放置 .htaccess 或修改 MAMP 的虚拟主机?

最佳答案

尝试过这个吗?应该在 .htaccesshttpd.confVirtualHost 中工作(通常放置在 httpd-vhosts.conf 中) > 如果您已将其包含在 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% Prevent Files from being cached

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.

来自http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html

如果您使用 .html 以外的扩展名,还可以选择为您要检索的模板文件添加扩展名。

关于apache - 如何防止 Apache httpd (MAMP) 中的 http 文件缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11532636/

相关文章:

javascript - CORS保护 : What is the point of HTTP_ORIGIN

apache - 您可以使用 htaccess 或在虚拟主机设置中禁用单个站点的 apache 日志吗?

java - Couchdb 通过 Httpclient 上传图片

php - Wordpress:建立数据库连接时出错和 Apache2 问题

java - 通过套接字手动发送 HTTP 请求

php - 从任何 URL 位置自动下载图像

django - Apache 剥离 "Authorization" header

apache - Apache 服务器端重定向

apache - 是否可以重定向子域但不能重定向子域的子域?

javascript - 打开地址栏中没有哈希值的 div