Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > php advanced caching and sessions

php advanced caching and sessions
Thread Tools
madmacgames
Grizzled Veteran
Join Date: Oct 2003
Status: Offline
Reply With Quote
May 5, 2004, 02:14 PM
 
I made a cache for our site to cache certain "blocks" on the pages to increase speed, however I neglected to account for sessions. When I was testing this I, it was only me and I have cookies enabled. The problem is, I do not really want to force users to have to use cookies, so on the 1st page anyone visits, a session ID is appended to the URLs, and then from thereon out, if the session cookie exists, the cookie is used rather than a session ID in the URL.

However, I failed to forsee this would mess up the caches. The limit is 24 hours per cached block, and I noticed today all of the cached blocks had a session ID hardcoded in them... oops

There are 2 solutions to caching with sessions that I know of. In my case, no content specific to the user is cached (expect for their session ID in the cached URLs). One solution is to require cookies, which would work great, but as I said, I don't want to force cookie usage. A 2nd solution would be to have personal caches, where your session has its own cache. I don't much like this either, as it does not gain the desired effect to increase the speed of the entire site, and not just the pages you've already visited, which your browser cache does anyways. And also this method could potentially consume alot of disk space, which isn't that big of a deal, as any cached files older than 24hrs are deleted.

Does anyone know of any other solutions?? I'm trying to think of a way to keep the global cache, because the cached content is the same for everyone, but allow the URLs to be for the correct session.

I suppose I could enable the cache for only cookie users, which would make the session ID showing up in the cached files a non-issue, and the non-cookie users would just not use any cache at all to keep their sessions in tact. I am leaning toward this solution, but was wondering what others thought first.

Thanks

PS. I just realized that google & other spiders are non-cookie users (no I did not just realize that). What I just realized was that certain areas, they would get different content that what normal (cookie using) users would get, because certain areas are say 9 things randomly selected & shown from say 36. This would likely change on each hit from google while only changing once every 24 hours for normal users. I think google could consider this cloaking (serving different content to spiders than normal users).

So that idea is out, unless I made it so spiders get served the cached content (checks are already in place to prevent them from starting sessions, so it wouldn't be too much more work to turn the cache on for them if I did the proposed solution)...

All of this is starting to sound like more trouble than it is worth though, unless I force cookie usage.
( Last edited by madmacgames; May 5, 2004 at 02:22 PM. )
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 03:30 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,