Apache - 如何在调试 htaccess 时禁用浏览器缓存 [英] Apache - how to disable browser caching while debugging htaccess

查看:27
本文介绍了Apache - 如何在调试 htaccess 时禁用浏览器缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试 .htaccess 文件.FireFox 不断缓存重定向,我无法绕过它们.通常我会按 Ctrl + F5,但因为它已经将我重定向到另一个页面,这只会刷新我发送到的页面而不是我输入的 url.有没有办法强制刷新 url?

这是一个例子:

  • 将example.com/hi 重定向到example.com/hello,在FireFox 中进行测试并正常运行
  • 从 .htaccess 中删除这一行
  • 在 FireFox 中输入 example.com/hi,它仍然重定向到 example.com/hello
  • 在 Chrome 中输入 example.com/hi,它不会重定向

这就是为什么我认为这是浏览器缓存问题,而不是服务器缓存问题.

这似乎是特定于 FireFox 的,一个快速的解决方案是改用 Chrome.缓存在一个小时后过期,尝试调试时时间太长了.

解决方案

如果您正在使用 RewriteRule,只需使用 R 而不是 R=301.出于其他目的,您必须在更改重定向时清除浏览器缓存.(如果您不知道如何清除浏览器缓存,在谷歌上搜索操作方法应该会提供一个快速简单的答案 - 或者随时发表评论,我会帮助您.)

简单地说,在您的重定向正常工作之前,尽可能避免 301.如果无法避免,请准备好定期清除浏览器缓存.

I'm trying to debug an .htaccess file. FireFox keeps caching redirects and I can't get around them. Normally I would hit Ctrl + F5, but because it has already redirected me to another page, that just refreshes the page I was sent to and not the url I typed in. Is there a way to force a refresh of a url?

Here's an example:

  • Redirect example.com/hi to example.com/hello, test in FireFox and it works
  • Remove this line from .htaccess
  • Type example.com/hi in FireFox, it still redirects to example.com/hello
  • Type example.com/hi in Chrome, it does not redirect

This is why I think it's a browser caching issue, not server caching.

Edit: This seems to be FireFox specific, a quick solution is to use Chrome instead. The cache expired after an hour, which is way too long when trying to debug.

解决方案

If you're using RewriteRule, just use R instead of R=301. For other purposes, you'll have to clear your browser cache whenever you change a redirect. (If you don't know how to clear your browser cache, googling for a how-to should provide a quick and easy answer - or feel free to comment and I'll help you out.)

Simply put, try to avoid 301s wherever possible until you've got your redirects working normally. If you can't avoid them, get ready to clear your browser cache regularly.

这篇关于Apache - 如何在调试 htaccess 时禁用浏览器缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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