Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache - how to disable browser caching while debugging htaccess

Tags:

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.

like image 520
hamboy Avatar asked Oct 12 '11 17:10

hamboy


People also ask

How do I disable caching in htaccess?

There are times when you must disable caching of your website files. To achieve this, you need a way to force any web browser accessing your site to not cache one or more types of files. For Apache web servers, the best solution is to edit . htaccess to disable caching.

Does Apache cache htaccess?

htaccess files are not cached by Apache. Every request causes a reparse, unfortunately.

What does browser caching reduce?

Caching is a feature in web browsing that allows recent web pages to be stored temporally in web browsers. This feature is important because it improves the page load time and reduces browsing costs. It is a resourceful technique that can be used by developers to improve web browsing experience.

Is browser caching secure?

For example, since cache information can contain sensitive data, it has to be protected from unauthorized access. In the case of Web applications, you would need to avoid caching confidential information on the user's browser in order to prevent accessing the data outside the control of the Web application.


1 Answers

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.

like image 174
Dan Ambrisco Avatar answered Oct 19 '22 04:10

Dan Ambrisco