PDA

View Full Version : Automatic refresh?


multilingual
24th November 2005, 10:11
I have a daily News section on two of my sites; they give up to date reports to people who are interested.

The service has proved to be quite popular and I am getting a good stream of regulars who come to the sites each day for the latest stories.

These pages are added every single day, but some people have emailed me saying that I have not put any new content on for a while and, 'is this service no longer operating?'.

I think that when they log on to the main News page of my site, their computer is showing them the cached page, which may be a few days old, depending on the last time they visited.

How can I make sure that the newest page is the one that they see?

Thanks for any help.

JB

JoyDivision
24th November 2005, 10:23
I think there are meta tags which let you state how long you want it to stay cached for. This where querystrings were good becuase a browser would always update a site with a ? after the URL. However there are lots of problems with querystrings which is why they are not often used these days.

PS If your clients are using Opera they will need to tell it up to update, as it just caches everything by default including forums.

DuaneJackson
24th November 2005, 10:51
I wrote the following function for ASP pages that I don't want cached:

function noCache()
response.addheader "Cache-Control", "no-store"
response.addheader "Cache-Control", "no-cache"
response.addheader "Pragma", "no-cache"
response.addheader "Cache-Control", "max-age=0, must-revalidate"
response.addheader "Expires", Now-1
end function

Rob Holmes
24th November 2005, 11:40
Try adding these to a .htaccess file

<Files *>
Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
Header set Expires: 0
Header set Pragma: no-cache
</Files>

Rob

webit
24th November 2005, 12:37
I alway add random values in the URL's for pages that I don't want cached, it's the only sure fire way IMO

DuaneJackson
24th November 2005, 12:39
I alway add random values in the URL's for pages that I don't want cached, it's the only sure fire way IMO

Ewww, not good for SEO. If you use ALL of the relevant cach-control, pragam and expiry headers then you should be fine.

webit
24th November 2005, 12:50
I alway add random values in the URL's for pages that I don't want cached, it's the only sure fire way IMO

Ewww, not good for SEO. If you use ALL of the relevant cach-control, pragam and expiry headers then you should be fine.

Fair point - we just use it for pages we dont want spidered such as sign up pages and stuff.

MichaelG
24th November 2005, 13:40
Try this javascript

Copy and paste between your <head></head> tag on the page. Change http://www.yourdomain.com/mynewpage.html to your domain/page.



<script type="text/javascript">
<!--//

var now = new Date();
var monthnumber = now.getMonth();
var monthday = now.getDate();
var year = now.getYear();

var today = year+""+monthday+""+monthday;

function getxPara(str) {
theleft = str.indexOf("=") + 1;
theright = str.lastIndexOf("&");
return(str.substring(theleft, theright));
}

if (getxPara(window.document.location.href) == "") {
window.location.href="http://www.yourdomain.com/mynewpage.html?today="+today+"&";
}

//-->
</script>

multilingual
24th November 2005, 16:27
Thanks for everyones help.

This sort of feedback is what makes UKBF such a great place.

:)

JB