Zen Cart Logo
Forums / General Questions / Page assets NOT caching

Page assets NOT caching

Views: 1,201

Results 1 to 9 of 9
10 May 2015, 3:45 PM
#1
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Page assets NOT caching

I can't figure out why page assets aren't being cached. I've used the steps here:
https://www.zen-cart.com/content.php?320-Speed-up-site-by-caching-page-assets

and here (currently in use):
http://gtmetrix.com/leverage-browser-caching.html

In both cases, css and js files are not being cached. It also says that a cache validator has not been set for gif files.

http://gtmetrix.com/reports/shopasgoodasgold.com/a2FxcxvI

The entire .htaccess is

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.shopasgoodasgold.com$
RewriteRule ^/?$ "http://shopasgoodasgold.com/" [R=301,L]

Redirect 301 /contest/index.html http://shopasgoodasgold.com/index.php?main_page=index&cPath=8_1

EXPIRES CACHING

<IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 1 month" ExpiresByType image/jpeg "access 1 month" ExpiresByType image/gif "access 1 month" ExpiresByType image/png "access 1 month" ExpiresByType text/css "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 month" ExpiresDefault "access 2 days" </IfModule> ## EXPIRES CACHING ##
10 May 2015, 4:02 PM
#2
bislewl avatar

bislewl

Totally Zenned

Join Date:
Dec 2011
Location:
Wisconsin, USA
Posts:
674
Plugin Contributions:
12

Re: Page assets NOT caching

I have had this issue when the server does not support mod_expires

11 May 2015, 2:14 PM
#3
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,290
Plugin Contributions:
39

Re: Page assets NOT caching

Or of mod_deflate is not enabled, also I prefer the following for your htaccess... note that some servers will need this in the assets directory such as includes/templates/your_template/css/

ExpiresActive On
ExpiresDefault A2592000 
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt|mpg|pdf|eot|svg|ttf|woff)$">
  ExpiresDefault A29030400
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\.(xml|txt|html|js|css)$">
  ExpiresDefault A2592000 
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\.(php|cgi|pl|htm|html)$">
  ExpiresDefault A0
  Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
  Header set Pragma "no-cache"
</FilesMatch>
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>

~Melanie

11 May 2015, 2:45 PM
#4
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Page assets NOT caching

If in the assets directory, is it still saved as an .htaccess file?

11 May 2015, 2:46 PM
#5
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,290
Plugin Contributions:
39

Re: Page assets NOT caching

yes, .htaccess

11 May 2015, 2:53 PM
#6
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Page assets NOT caching

Thanks for confirming.

I've tried your code (adding it to includes/templates/your_template/css/ didn't make a difference) and it's now reporting that content is being cached! Very oddly though, it says a validator is not specified for gif and png. :huh:

11 May 2015, 4:43 PM
#8
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,017
Plugin Contributions:
2

Re: Page assets NOT caching

One thing I cannot fathom with many web optimisation sites is their focus on compressing images. My four largest template images are 10-12 Kb (including down for maintenance) each, but I have hundreds of others mostly well under 3kb. Yet the reports say I should compress the larger images further to gain a saving of up to 55%. Really! 55% of 40Kb would produce a saving of only 21Kb. I am so mortified.

11 May 2015, 4:51 PM
#9
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Page assets NOT caching

dw08gm:

One thing I cannot fathom with many web optimisation sites is their focus on compressing images. My four largest template images are 10-12 Kb (including down for maintenance) each, but I have hundreds of others mostly well under 3kb. Yet the reports say I should compress the larger images further to gain a saving of up to 55%. Really! 55% of 40Kb would produce a saving of only 21Kb. I am so mortified.

I agree completely! You'd think these tools would be built to understand that actual savings as related to page speed and not just the percentage in file size.