Updating Website

Updating Website

Posted by: kaveshla
Posted on: 2008-05-09 09:05:00

How can I ensure that my visitors are viewing the most up date version of my site?

Re: Updating Website

Posted by: scjessey
Posted on: 2008-05-09 09:48:00

In reply to:

How can I ensure that my visitors are viewing the most up date version of my site?


I assume you are referring to issues involved with page caching. There are a couple of meta elements you can add to the <head> of your documents that can indicate caching is undesirable, but these aren't necessarily supported by all browsers:

<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">

The latter meta element is really for older browsers. A more robust method is to use HTTP headers to deal with this. For maximum redundancy, set the headers like this:

Cache-Control: no-cache
Pragma: no-cache

If you are using PHP, you can set headers by placing statements at the top of your document like these:

<?php
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>

-- si-blog --

Re: Updating Website

Posted by: kaveshla
Posted on: 2008-05-09 11:14:00

Thanks so much for your response!

the HTTP header method sounds more like what I'm looking for..

Would it be possible to explain how to go about this in more detail?


Thanks

Re: Updating Website

Posted by: scjessey
Posted on: 2008-05-09 13:21:00

Assuming your Apache installation is running the mod_headers Apache module (and I think most are), you can set the headers in your .htaccess file like this:

Header set Cache-Control "max-age=0, no-store"

Ignore the "pragma" thing I mentioned earlier - it shouldn't be needed on the DreamHost setup and it would essentially create an invalid server response. If you want to restrict this behavior to a specific file or group of files, you could do something like this:

<Files index.html>
Header set Cache-Control "max-age=0, no-store"
</Files>

Or this:

<Directory "/home/username/domain/path/to/folder-you-don't-want-cached">
Header set Cache-Control "max-age=0, no-store"
</Directory>

-- si-blog --

Re: Updating Website

Posted by: kaveshla
Posted on: 2008-05-09 14:33:00

Sweet! I'll let you know how it goes. Thanks again.

Re: Updating Website

Posted by: kaveshla
Posted on: 2008-05-09 15:05:00

Used the first htaccess setting and everything seems to be working as planned!

THANKS SO MUCH!.



Re: Updating Website

Posted by: patricktan
Posted on: 2008-05-09 23:28:00

I did not know this. Apache is so sweet!