views:

71

answers:

4

I would like for my site when someone clicks "Back" or "Forward" for the server to tell the browser to load the cache instead of reloading the entire page. I've tested some headers and done research, but I can't seem to get this to function as intended.

Update: The if-modified since header is not something I'd like to do. There's got to be more general options when it comes to caching. Even if it doesn't work in every browser (though that would be ideal) even just Firefox/Chrome would be excellent.

+4  A: 

I think you'll find that no matter what you do, the 'Back' button functionality may or may not listen...the functionality differs from browser to browser and isn't up to the page being viewed.

There are plenty of tips and tricks for getting the browser to do what you want...but in the end it's up to whoever coded the browser if they want to listen or not.

Justin Niessner
A: 

As far as i know there is no other way then using something like ZendCache or MemCache for those kind of things.

There reason is, in my optionion, that the server can't tell if the browser got the page cached or not so the server always send the full content, and executing the php script.

Using a seperate cache server (like zend or memcache) you can just forward the plain html without going through the whole script again.

+1  A: 

Check for the If-Modified-Since header before you output anything --- if it is recent enough, return a 304 Not Modified http status code and do not output the page.

Dave Hinton
+1  A: 

You can conrol this behaviour with the Cache-Control header. This tutorial seems to be fairly comprehensive: Caching Tutorial

troelskn
I used that tutorial, what I have is doing much more than back/forward as I need it to.
Webnet