Forum Moderators: open

Message Too Old, No Replies

how to no-cache?

         

Dan99

10:51 pm on Jan 17, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month



I look at my webpage with my browser, upload a new web page to my server, and look at it again. It's unchanged! Clearly it was just cached and not reloaded. How do I tell the browser not to cache my web page?

My page has

<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">
<title>my title</title>
</head>


But that doesn't seem to do the trick.

keyplyr

11:09 pm on Jan 17, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The problem with trying to not cache is there are too many players:

• ISPs cache to save bandwidth

• Net Blocks sometimes employ caching to reduce redundancy

• Browsers have default cache setting to improve load time.

The Meta Tags are no longer universally supported (some agents do, most don't.) Better to do it at the server level. This line of code would be used at the top of your .htaccess file:
Header set Cache-Control "max-age=0"

However, you'll still only achieve limited success.

Depending on which browser you personally use, there may be a browser setting you can adjust to help reduce the persistent caching.

lucy24

12:47 am on Jan 18, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Header set Cache-Control "max-age=0"
On my test site I use
ExpiresActive On
ExpiresByType text/html "access"
which also seems to work. It's a bit rough on the occasional human whose browser then has to re-request a page they only visited five minutes ago, but it can’t be helped.

There are heaps of different ways to set caching preferences*, but in the meantime you can always refresh the page manually. If this doesn't work, you know that the fault lies with your ISP--and good luck getting them to do what you want.

Think twice about setting no-cache-at-all globally. How often do you really change your images and similar resources? In general it's better to set different times for different types of material.


* Just the other day I finally looked up what the heck “Pragma” means in a request, and learned it’s simply an old-fashioned synonym for “Cache-Control”.

Dan99

1:30 am on Jan 18, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month



Ah, excellent. Thank you for the explanation and advice. I'll try those.

Dan99

3:05 pm on Jan 18, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month



Um, lucy24, when I use your code in my <head>, my web page prints out

"ExpiresActive On ExpiresByType text/html "access"

at the top whenever it is called up by a browser. Is this code not supposed to be in <head>?

phranque

3:15 pm on Jan 18, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



that goes in your .htaccess file.

Dan99

3:32 pm on Jan 18, 2018 (gmt 0)

10+ Year Member Top Contributors Of The Month



Oh oh oh. Thanks. That should have been clear, and keyplyr said that explicitly. More coffee!