php 如何在 Apache-XAMPP 中禁用 Apache 缓存?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10848055/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable Apache caching in Apache-XAMPP?
提问by Dhananjay
I am having this weird problem with my XAMPP-Apache. I am making an log-in system where form is posted to redirect.php page. I updated the redirect.php and but still it is showing me the same old result. There is not even a single line to redirect(header fn call) it to another page but still it redirects to home.php page as it was doing in older script. I tried clearing cache of my browser and changing the browser for testing but didn't work...I even tried rebooting the server but no change. Please help me through....
我的 XAMPP-Apache 遇到了这个奇怪的问题。我正在制作一个登录系统,将表单发布到redirect.php 页面。我更新了redirect.php,但它仍然显示相同的旧结果。甚至没有一行将它重定向(header fn call)到另一个页面,但它仍然像在旧脚本中那样重定向到 home.php 页面。我尝试清除浏览器的缓存并更改浏览器进行测试,但没有奏效……我什至尝试重新启动服务器,但没有任何变化。请帮我度过难关....
回答by Siddhesh
Tried this? Should work in both .htaccess, httpd.confand in a VirtualHost (usually placed in httpd-vhosts.conf if you have included it from your httpd.conf)
试过这个吗?应该在.htaccess,httpd.conf和 VirtualHost 中工作(通常放在 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. From http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html
100% 防止文件被缓存
这类似于谷歌广告如何使用标题 Cache-Control: private, x-gzip-ok=""> 来防止代理和客户端缓存广告。来自 http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html
And optionally add the extension for the template files you are retrieving if you are using an extension other than .html for those.
如果您使用 .html 以外的扩展名,则可以选择为正在检索的模板文件添加扩展名。
回答by xboomx
If request is identical, it's possible that you receiving response from cache.
如果请求相同,您可能会收到来自缓存的响应。
Solution 1:
解决方案1:
You can try to have every time unique request by adding for example time stamp.
您可以尝试通过添加例如时间戳来获得每次唯一的请求。
Solution 2 (not every server will accept - depend on server setting):
解决方案 2(并非每个服务器都会接受 - 取决于服务器设置):
You can set header params to your request like:
您可以为您的请求设置标头参数,例如:
'If-Modified-Since' = 'Mon, 26 Jul 1997 05:00:00 GMT'
'Cache-Control' = 'no-cache'
'Pragma' = 'no-cache'
Solution 3:
解决方案3:
Play with server config :)
玩服务器配置:)
回答by Anton R
comment this part in httpd.conf:
在 httpd.conf 中评论这部分:
LoadModule cache_module modules/mod_cache.so
LoadModule cache_module modules/mod_cache.so

