如何防止Apache httpd(MAMP)中的http文件缓存 [英] How to prevent http file caching in Apache httpd (MAMP)

查看:181
本文介绍了如何防止Apache httpd(MAMP)中的http文件缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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.

来自 http://www.askapache.com/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文件缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆