Page 1 of 1

Cache problems

Posted: Mon Oct 16, 2006 5:34 pm
by bob_the _builder
Hi,

Im prolly not posting in the correct place ..

I have a cache problem with my image gallerys and members image in their profile.

If a member changes their picture (using php + gd script) then hit the link to view thier profile the old image shows untill a page refresh is performed.

Same when they upload an image, I display a preview of the uploaded image with the success message, this also shows cached images often.

Can this be stopped?


Thanks

Posted: Mon Oct 16, 2006 5:59 pm
by feyd
Change the filename. For instance, phpBB stores the images as a hash result. What you hash could be the results of microtime() for example.

Posted: Mon Oct 16, 2006 6:43 pm
by bob_the _builder
Ahh, I have it so it changes the image name to the users id + filetype prior to storing it in the database.

When they update it, basiaclly the existing image gets unlinked and updates the name with the userid + file extension.

Is there away to stop the cache problem keeping the naming stucture of the uploads.


Thanks

Posted: Mon Oct 16, 2006 9:45 pm
by feyd
You could shift the image link to a script (that outputs caching control headers) or add a randomized query string to the URL that makes no difference in the actual request, but does affect the knowledge of the browsers' caching mechanisms.