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

编程入门 行业动态 更新时间:2024-10-20 13:28:48
本文介绍了如何防止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.

来自 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文件缓存

本文发布于:2023-11-01 01:35:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   如何防止   文件   Apache   MAMP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!