How to tell browser to cache all images?

ron13315

Member
Joined
Jul 23, 2014
Messages
280
Points
18
Hi, im thinking a way to make the site with a lot of images to load faster.

i want all the images to be cached if loaded once in a browser so the next visit the site will load fast.


I tried to insert this following code in my .htacess but no seem to work.

Code:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

Code:
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
 

Dopani

Active member
Joined
Mar 11, 2014
Messages
324
Points
28
These codes are putted in .htaccess file

How you know it didn't work?
 

ron13315

Member
Joined
Jul 23, 2014
Messages
280
Points
18
Hi sir @developer here is the site link [URLnf="http://hyipscope.org/"]please view here[/URLnf]



here is the current code i have in my htaccess

<IfModule mod_headers.c>
<filesMatch ".(css|jpg|jpeg|png|gif|js|html|ico)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
</IfModule>
 

Developer

Active member
Joined
Dec 21, 2015
Messages
412
Points
43
Ron, is this site on a shared hosting account, VPS or a dedicated server?
 

Developer

Active member
Joined
Dec 21, 2015
Messages
412
Points
43
Also, try the following (as minute as the changes may seem, please try and let me know if this works)

REPLACE THIS:
Code:
<filesMatch ".(css|jpg|jpeg|png|gif|js|html|ico)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
WITH THIS:
Code:
<FilesMatch "\.(css|jpg|jpeg|png|gif|js|html|ico)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
 

ron13315

Member
Joined
Jul 23, 2014
Messages
280
Points
18
the site is on VPS

this code is still not working.

<FilesMatch "\.(css|jpg|jpeg|png|gif|js|html|ico)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
 

Developer

Active member
Joined
Dec 21, 2015
Messages
412
Points
43
Developer
Did you place it outside (or inside still) the "IfModule"
set? If still within, try unwrapping the "ifmodule" and
see if that helps...

Also, since I know almost nothing about how VPS's work
forgive me if this question sounds stupid, but, do you have
your own apache.conf file and have you checked all of the
configurations to enure all the settings are correct within
your conf file?
 
Last edited:

ron13315

Member
Joined
Jul 23, 2014
Messages
280
Points
18
yes i tried both inside and outside "IfModule" still not working.

ill try to look about the apache.conf file
 
Newer threads
Replies
5
Views
2,770
Replies
7
Views
3,229
Replies
34
Views
9,684
Replies
4
Views
1,884
Latest threads
Replies
1
Views
51
Replies
1
Views
53
Replies
1
Views
134
Replies
1
Views
163
Replies
1
Views
262
Recommended threads
Replies
5
Views
3,279
Replies
3
Views
2,800
Replies
11
Views
5,206
Replies
2
Views
1,122

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top