Sometimes it's handy to have the browser cache an entire page including anything that is entered into a form. What if a user has filled out an entire form but accidently clicks refresh or another link, and when they click back the form is empty. Anoying! This also works if you submit to an error checking page, and you want the browser to remember the form data instead of writing something in PHP. How to do this is below.
The easiest way to tell the browser that they can cache the page is by doing this:
header("Cache-Control: private, max-age=10800, pre-check=10800");
header("Pragma: private");
header("Expires: " . date(DATE_RFC822,strtotime("+2 day")));
Only do this on pages that are not dynamic, as the browser will keep this page in cache for 2 days.
Put the above code AFTER any session_start(); if you are using sessions.
And that's how to control cache when back button clicked.
|
Collector Comics is THE place to buy, sell, and research comics online. Launching soon.
Launch »
Screenshot »
|
|
Webitor is a kick-ass easy to use, easy to extend, non-database driven Content Management System. Version 2 with reseller plan coming soon.
Launch »
Version 1 »
|
|
GC Lounge is my own pet social network and test bed for social related code. Made by locals for locals.
Launch »
|
|
GG has indexed over half a million recent Trade Mark applications. This revolutionary tool is extremely valuable for industry experts.
Launch »
|
|
GCWiFi is the hub for techies interested in joining a ad-hoc wireless mesh spread across the Gold Coast
Launch »
|
|
Web based financial client management system
Launch »
|
|
OS Commerce modules and template modification
Launch »
|
| View More Projects » | |