Forum Moderators: open

Message Too Old, No Replies

Need my homepage NOT to be cached

Using pragma not working?

         

silverbytes

5:10 pm on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I change my home page html daily so I put this

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

trying to avoid my page to be cached and thus give users daily updated information since I publish some dates.

But I see in my IE my pages cached anyway so I guess that doesn't work.

How do I make non caching pages?

encyclo

8:09 pm on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The meta tags tend to be pretty ineffective, and they are never read by ISP proxy caches, for example - so you can't count on them.

The easiest way to make a non-cacheable page is to use a server-side scipting language such as PHP or ASP - as the page is generated each time and many PHP/ASP sites include highly dynamic content, the result is not cacheable by default. If you are using static HTML served from an Apache server, then you can use the mod_expires [httpd.apache.org] and mod_headers [httpd.apache.org] directives to control caching.

silverbytes

10:28 pm on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks the html option / apache is what I need I think. But I don't understand what can I do about it... is it something I must modify on my hosting cpanel?

Span

10:40 pm on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An example for your .htaccess:


ExpiresActive On
<FilesMatch "^index\html$">
ExpiresDefault A0
Header unset Cache-Control:
Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>

I don't know if you can do something like that with CPanel. I use hosts without any panel. If you can't, you have to download your .htaccess and edit it yourself with a plain text editor.

silverbytes

1:14 am on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have access to .htaccess (where I have some bots banned and redirects) it looks like this:


RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^209\.237\.232\.84$ [OR]
RewriteCond %{HTTP_USER_AGENT} ZyBorg/1\.0\ \( [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule .* - [F]
Redirect permanent /foo.htm http://www.mysite.com/

Should I add that at the end?
What does exactly the code you mention?

Span

1:41 pm on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The expiry code can go anywhere.

I added comments above every line to explain what it does


# Turn the module on
ExpiresActive On
# if filename matches "index.html"
<FilesMatch "^index\.html$">
# this file expires in 0 seconds
ExpiresDefault A0
# remove existing Cache-Control header
Header unset Cache-Control:
# add this header
Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>

You can check your page headers with the Header checker in your profile.
For more info: mod_expires [httpd.apache.org], mod_headers [httpd.apache.org]

silverbytes

2:48 pm on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Added that code at the end of my .htaccess and a 500 error apeared so I had to remove it...

encyclo

3:08 pm on Aug 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The 500 Server error is triggered on my server too (specifically by the Header directives). Investigating... ;)

silverbytes

11:08 pm on Sep 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Still without answer to my problem... does anybody knows how to force my page to not be cached?

Span

3:31 pm on Sep 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use the same code without a 500 server error. Maybe mod_expires or mod_headers is not supported?

[There's a typo in the second line of msg#4 - forgot the . in "^index\.html$"]