Cache Images to Improve Loading Time via .htaccess?

Status
Not open for further replies.

shulk101

New Member
Messages
6
Reaction score
0
Points
1
Hi,
I was wondering how I could go about caching all my jpg/jpeg/png images to the browser so they don't have to load every time I go to another page. The images cache when I upload them to a file hosting site (servimg), but not when I upload them to my "images" directory. Is there any way I can go about caching all of them via the .htaccess file?

Thanks.
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

Your .htaccess file in your public_html directory contains this line:
Header set Cache-Control "max-age=0, private, no-cache, no-store, must-revalidate"

This header not only gets sent to Varnish, but it also gets sent to browsers, so browsers won't cache your images. If it's important that you have Varnish cache disabled for the rest of your site, you might want to wrap this line so that it doesn't affect files ending with jpg/jpeg/png extensions. This directive might help with that. ;)

Thank you,
 
Status
Not open for further replies.
Top