SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: sessions and cache issue
-
Jun 19, 2001, 15:35 #1
- Join Date
- Feb 2001
- Location
- The Netherlands
- Posts
- 256
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
sessions and cache issue
To enable the use of the back button in combination with sessions, I added the following line to the top of my pages:
ini_set("session.cache_limiter","public");
This works well, but now I have the problem that when someone clicks on a link they see the 'old' cached page which doesn't reflect the latest changes.
What I would like is the following:
-When people use the back button they should see the cached page
-When they click on a link they should see the "non-cached" page which reflects the latest changes.
How can I accomplish this?
-
Jun 19, 2001, 15:47 #2
- Join Date
- Mar 2001
- Location
- Tampa, FL
- Posts
- 376
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You need to send a no-cache header, here is a sample of one.
PHP Code:header("Expires: Mon, 14 Jul 1996 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
I hope that helps.
-
Jun 19, 2001, 16:34 #3
- Join Date
- Feb 2001
- Location
- The Netherlands
- Posts
- 256
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If I don't cache the page then the back button won't work, so the nocache headers would not help here.
When I use sessions my pages are not cached by default.
That's why i used : ini_set("session.cache_limiter","public");
Now the pages are being cached and the back and forward button works, but I need the browser to show the 'newest' pages instead of the cached ones.
How can I enable the use of the back and forward buttons in combination with sessions and have the browser display the most recent changes when people click on a link?
I hope I'm clear enough
-
Jun 19, 2001, 16:56 #4
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can trick the browser into not caching the links when people click on them by tacking on a unix timestamp on the end of the link, this way the browser thinks its a new page and you will fool the cache into thinking that way too.
<a href="somelink.php?somevar=someval&ck=<?=time()?>">go there</a>
I use ck it stands for cache killer, but you can use whatever as long as it doesn't conflict with some other var you may be using. I hope that helps.Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jun 19, 2001, 18:37 #5
- Join Date
- Mar 2001
- Location
- Tampa, FL
- Posts
- 376
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
freddy is right, you could try that.
my version was only to have ti clean out the cache to fetch a page, but it does eat the users bandwith trying to reload every page.
-
Jun 20, 2001, 00:50 #6
- Join Date
- Feb 2001
- Location
- The Netherlands
- Posts
- 256
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I tried Freddy's suggestion and it works!
Freddy and Theiggsta, thank you for your help!
Bookmarks