Portal Home > Knowledgebase > Articles Database > Caching the Image


Caching the Image




Posted by ashras99, 01-09-2010, 08:06 PM
I am caching my site jpg images using the htacess file and here is the code.. Header set Cache-Control "max-age=604800" But this cache all the jpg files on that page, i like to cache only few certain folders because some images, change daily and some in a weeks time. So, please tell me how to define the cache control for certain path?

Posted by warddr, 01-09-2010, 09:07 PM
Well, I probably got another solution for you: you could just change your php script a litle, php is reloaded every time the page is refreshed. You can add ?something to the url of your images. If you change that ?something to something else , the webbrowser doesn't have that file in cache and will get the "new" image from te server.

Posted by Dr:linux, 01-10-2010, 03:05 AM
If you are trying to modify the caching of a jpg file there are some easy ways. Just copy paste text similar below the file named .htacess in the directory for the file that you wish to change the file caching behavior. This is for the case of a jpg and HTML files. >>> There is cache control system which can be used for setting cache on what content can be cached and what cannot. For example to set the Cache-Control setting for a folder or directory named "Images" in the default website, Adsutil.vbs is used.. 1. Open a command prompt and change to your C:\InetPub\AdminScripts folder. 2. Run the following command: CSCRIPT ADSUTIL.VBS SET W3SVC/1/ROOT/images/CacheControlCustom "no-cache". Let me know if you have any queries..

Posted by ashras99, 01-10-2010, 07:00 AM
I have a Linux server and CentOS 5.4 is installed. I think Dr. Linux solution work on windows servers.

Posted by foobic, 01-10-2010, 08:08 AM
So this is a dedicated server or VPS? If so, use the Directory directive to set a path on which your cache control header should be set. Note that you can't use this in .htaccess - it needs to go in the main config file (httpd.conf typically) or in the vhost config.

Posted by mattle, 01-11-2010, 12:47 PM
Ironic



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Reseller Packages (Views: 629)