Hey Guys,
I did visit the various resources in the forum regarding optimizing the htaccess file and did read all the nice work Chris provided in his Sticky , but when I test my site in Google Developer Tool, it’s still complaining that I am not caching any resources , I know it’s not on the Theme guys to optimize but I was hoping you’d at least point me in the right direction, Here’s a paste of my .htaccess , I am hosted with Blushost managed WP:-
# Use PHP5.4 Single php.ini as default
#AddHandler application/x-httpd-php54s .php
# Begin WordPress
<IfModule mod_deflate.c>
<filesMatch “\.(js|css|html|php)$”>
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 5 seconds”
ExpiresByType image/x-icon “access plus 604800 seconds”
ExpiresByType image/jpeg “access plus 604800 seconds”
ExpiresByType image/png “access plus 604800 seconds”
ExpiresByType image/gif “access plus 604800 seconds”
ExpiresByType application/x-shockwave-flash “access plus 604800 seconds”
ExpiresByType text/css “access plus 604800 seconds”
ExpiresByType text/javascript “access plus 604800 seconds”
ExpiresByType application/javascript “access plus 604800 seconds”
ExpiresByType application/x-javascript “access plus 604800 seconds”
#ExpiresByType text/html “access plus 600 seconds”
#ExpiresByType application/xhtml+xml “access plus 600 seconds”
</ifModule>
# END Expire headers
AddType text/javascript .js
<IfModule mod_rewrite.c>
ExpiresActive On
# Favicon (cannot be renamed)
ExpiresByType image/x-icon “access plus 1 week”
# Media: images, video, audio
ExpiresByType audio/ogg “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType video/mp4 “access plus 1 month”
ExpiresByType video/ogg “access plus 1 month”
ExpiresByType video/webm “access plus 1 month”
# CSS and JavaScript
ExpiresByType application/x-javascript “access plus 1 week”
ExpiresByType text/css “access plus 1 week”
ExpiresByType text/javascript “access plus 1 week”
# Webfonts
ExpiresByType application/vnd.ms-fontobject “access plus 1 month”
ExpiresByType application/x-font-ttf “access plus 1 month”
ExpiresByType application/x-font-woff “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType image/svg+xml “access plus 1 month”
</IfModule>
Cheers
@linearwhiz I’m sorry that i’ve lost your message and I’m replying so late but here is our .htaccess
<IfModule mod_deflate.c>
<filesMatch "\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 904800 seconds"
ExpiresByType image/jpeg "access plus 904800 seconds"
ExpiresByType image/png "access plus 904800 seconds"
ExpiresByType image/gif "access plus 904800 seconds"
ExpiresByType application/x-shockwave-flash "access plus 904800 seconds"
ExpiresByType text/css "access plus 904800 seconds"
ExpiresByType text/javascript "access plus 904800 seconds"
ExpiresByType application/javascript "access plus 904800 seconds"
ExpiresByType application/x-javascript "access plus 904800 seconds"
#ExpiresByType text/html "access plus 600 seconds"
#ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers
Here’s mine, although this has some stuff for mod_pagespeed at top, and I also unset tag, and am trying to block pingbacks. 🙂
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters collapse_whitespace
ModPagespeedEnableFilters remove_comments
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters insert_dns_prefetch
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
AddType text/javascript .js
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
# BEGIN Expire headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2500000 seconds"
ExpiresByType image/jpeg "access plus 2500000 seconds"
ExpiresByType image/png "access plus 2500000 seconds"
ExpiresByType image/gif "access plus 2500000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2500000 seconds"
ExpiresByType text/css "access plus 700000 seconds"
ExpiresByType text/javascript "access plus 700000 seconds"
ExpiresByType application/javascript "access plus 700000 seconds"
ExpiresByType application/x-javascript "access plus 700000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
ExpiresByType font/truetype "access plus 2500000 seconds"
ExpiresByType font/opentype "access plus 2500000 seconds"
ExpiresByType application/x-font-woff "access plus 2500000 seconds"
ExpiresByType image/svg+xml "access plus 2500000 seconds"
ExpiresByType application/vnd.ms-fontobject "access plus 2500000 seconds"
</IfModule>
# END Expire headers
# BEGIN Cache-Control Headers
<IfModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</IfModule>
# END Cache-Control Headers
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
<IfModule mod_alias.c>
RedirectMatch 403 /xmlrpc.php
</IfModule>
-
This reply was modified 11 years by
simchris.
Thanks for chipping in Chris , I’ve “borrowed” your hta access code and it made a real difference.
There’s a small issue I am having with images though, I upload all my images to Amazon’s S3 and am using Amazon’s Cloudftont CDN as well , these images don’t have any expiry headers when I test , Do you think we could do anything about that ?
I could PM you more details if you’d be interested ..
Cheers,
Wissam
You can set an expiration time in your Amazon CDN; I used to use that. It’s in their help docs, but I abandoned that about this time last year since I found in our case with our own dedicated server and running mod_pagspeed, etc., it didn’t appreciably help us.
There is a setting in the master account, where you can set the TTL (time to live) for the “bucket” — I was setting mine to one year. It’s bee nawhile, unfortunately.
This may help
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html#ExpirationAddingHeadersInS3
I think at the time they didn’t have a setting for that; you could set how long the files live before the “expire” them– which I set to one year. I don’t remember how I set the expirations “per file.”
#EDIT#
oh stupid me (looking at my windows desktop this morning) … there is no easy way to do that. I bought software to actually do that properly (FYI: we got a brand spanking new web server Jan 2015, and I spent month of January testing every possibly way to boost pagespeed score, with the Newspaper theme and also our bootstrap based static HTML stuff used for our main business site — this included testing Amazon CDN for assets).
Go out right now and buy a copy of “Cloudberry S3 Explorer” software — this allows you to manage your buckets, set expiration headers, etc. — it’s like a shell application for your S3 account. It’s freeware, but if you are going to actually use S3 it’s the only way to fly — seriously.
The $39 pro version is totally worth it. I highly recommend it. Saved me hours of hair pulling (not my hair, just random passerby…. 😉
http://www.cloudberrylab.com/free-amazon-s3-explorer-cloudfront-IAM.aspx
HOW TO
http://www.cloudberrylab.com/blog/how-to-set-custom-http-headers-for-amazon-s3-objects-with-cloudberry-explorer/
Thanks a lot Chris , I will defiantly look into Cloudberry later on this week.
This page speed optimization Gig gives you such great satisfaction even for a single percentage point improvement, but I have to say it’s such a time consuming work man , so I really appreciate your help.
Wissam.