View Full Version : Cache buttons etc images
Gearloose
06-04-2005, 08:44 PM
Is there a way of caching only some groups of images and not all of them?
E.g. I want the browser to use its cache for buttons, IM images, smilies (maybe and some other groups of images that don't change in every visit) but I don't want it to use the cache for status icons and the rest of the images that may have changed from the previous time that a user visited the forum.
Sinse some group of images don't change (while other change in every visit of a member in the forum) is there a way to do it?
I asked this in vb.com and Steve said that he is not sure this is even possible but if so it requires modifying the code.
Do you think is it possible to achieve something like this?
Is there something like this available, or could someone point me in the right direction so I can make a hack for this?
Andreas
06-05-2005, 12:28 AM
That doesn't make sense at all, as the images never change (except if you upload new ones).
But if you really want to do that put this as .htaccess in the appropriate directory
ExpiresActive On
ExpiresDefault A0
Header unset Cache-Control
Header append Cache-Control "no-cache, must-revalidate"
Please note that this requires Apache with mod_expires and mod_headers
Gearloose
06-05-2005, 12:47 AM
Thanks for the answer but as I posted in vb.com (I saw the answer there first):
Let me clearify it:
The buttons are the same always for all the members.
BUT...
The statusicons are not as e.g. some thread could have the "No New Posts" icon now, but when I come back tommorow it could have the "New Posts" icon.
Is it clearer now what I mean?
So, I'd like to find a way to use the browser's cache for only those images who don't change from one visit to the next one.
If I'm not mistaken, I think your .htaccess solution that you gave above is not what I want.
Oops! I just noticed this!
if you really want to do that put this as .htaccess in the appropriate directory
Do you mean, it is directory specific?
If so, should I put this in the directory of the images that I want to be cached or in the directory of the images that I want to not be cached?
Andreas
06-05-2005, 12:59 AM
Do you mean, it is directory specific?
If so, should I put this in the directory of the images that I want to be cached or in the directory of the images that I want to not be cached?
Yes. You have to place this in the directory where you don't want images to be cached.
But as I already said, the images "never" change.
What actually does change are the image URLs within the HTML that is being generated by vBulletin (eg. <img src="...statusicon/post_new.gif" ...> and <img src="...statusicon/post_old.gif" ...> for example)
If you see wrong images, you most likely have problems with a (faulty) proxy.
To get around this, you would have to disable caching:
ACP / vBulletin Options / Cookies and HTTP Header Options / [X] User No-Cache Headers
However, this might/will increase bandwidth usage and server load.
Gearloose
06-05-2005, 01:06 AM
I currently use the No-cache option.
I saw in the vb.com that it is recommented to use no-cache so the members always get the most fresh contents without caching problems. I just would like to use the cache for the images that don't change neighter their URLs as you said.
Andreas
06-05-2005, 01:11 AM
Then you don't have to do anything, the browser will cache the images (at least it should IIRC).
Gearloose
06-05-2005, 01:17 AM
No, my browser always fetches the images from the site (both IE and FF configured to use cache).
Since I have the "User No-Cache Headers = YES" isn't it the way that the browser should work? I mean, I have set "User No-Cache Headers = YES" to not-cache anything from the site, so the browser does just that.
Am I missing something?
Andreas
06-05-2005, 01:40 AM
Hmm, I do have Use No-Cache Headers set to Yes, but Firefox uses the Cache for images.
Try the following with Firefox:
Clear the Cache, close all Firefox instances.
Open LiveHTTPHeaders.
Visit some forums/threads at your board, then attach the LiveHTTPHeaders Log here.
Attention This Log does contain cookie information, you must strip the cookies bbsessionhash and bbpassword first
Gearloose
06-05-2005, 02:55 AM
Hmm, I do have Use No-Cache Headers set to Yes, but Firefox uses the Cache for images.
I cleared the cache and now FF works as you said. (I don't know why it wasn't working that way before.)
I tried the same with IE, but with no luck. (Even here, IE always fetched the images from the site.) I guess I have to check this, with some of my members to see how their IE is working.
I made some testing with both FF and IE in my forum. FF works just fine now. But IE still refuses to use the cache... to be more specific: it uses the cache for the images of the previous page that I was viewing and not for any other image. E.g. if I press "Post Reply" it shows immediatly the smilies that was in the thread's page that I was viewing, but not the rest of the smilies. Is this normal?
(I just downloaded LiveHTTPHeaders. Do you still think that it would help to paste a log here?)
Thanks again.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.