Site logo

Archived topic

Exploiting the browser caching

6 replies · Started by Philippe on May 27, 2015

Viewing posts 1–7 of 7

This is a very nice plugin but it does not define a timeout cache images, if by chance you have another idea?

You may have to go with something like W3 Total Cache to get that kind of flexibility.

I already use WP Fastest Cache which is the best cache plugin of those I tested.

I have I modified the file ".htaccess" by adding (from http://www.deepintheweb.com/optimiser-un-fichier-htaccess/) :

# BEGIN Cache-Control Headers
<ifmodule mod_headers.c>
 <filesmatch "\\.(ico|jpe?g|png|gif|swf|gz|ttf)$">
 Header set Cache-Control "max-age=2592000, public"
 </filesmatch>
 <filesmatch "\\.(css)$">
 Header set Cache-Control "max-age=2592000, public"
 </filesmatch>
 <filesmatch "\\.(js)$">
 Header set Cache-Control "max-age=2592000, private"
 </filesmatch>
<filesmatch "\\.(html|htm)$">
Header set Cache-Control "max-age=7200, public"
</filesmatch>
# Disable caching for scripts and other dynamic files
<filesmatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</filesmatch>
</ifmodule>
# END Cache-Control Headers

RewriteEngine on
#Check to see if browser can accept gzip files. If so and we have it – serve it!
ReWriteCond %{HTTP:accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
#make sure there’s no trailing .gz on the url
ReWriteCond %{REQUEST_FILENAME} !^.+.gz$
#check to see if a .gz version of the file exists.
RewriteCond %{REQUEST_FILENAME}.gz -f
#All conditions met so add .gz to URL filename (invisibly)
RewriteRule ^(.+) $1.gz [QSA,L]
<ifmodule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_keep_workfiles No
mod_gzip_can_negotiate Yes
mod_gzip_add_header_count Yes
mod_gzip_send_vary Yes
mod_gzip_command_version ‘/mod_gzip_status’
mod_gzip_min_http 1000
mod_gzip_minimum_file_size 300
mod_gzip_maximum_file_size 512000
mod_gzip_maximum_inmem_size 60000
mod_gzip_handle_methods GET POST
mod_gzip_temp_dir /tmp
mod_gzip_item_include file .html$
mod_gzip_item_include file .php$
mod_gzip_item_include file .pl$
mod_gzip_item_include file .rb$
mod_gzip_item_include file .py$
mod_gzip_item_include file .cgi$
mod_gzip_item_include file .css$
mod_gzip_item_include file .js$
mod_gzip_item_include mime ^application/javascript$
mod_gzip_item_include mime ^application/x-javascript$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^httpd/unix-directory$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include handler ^server-status$
mod_gzip_item_include handler ^server-info$
mod_gzip_item_include handler ^application/x-httpd-php
mod_gzip_item_exclude mime ^image/.*
</ifmodule>

# BEGIN Expire headers
<ifmodule mod_expires.c>
 ExpiresActive On
 ExpiresDefault "access plus 7200 seconds"
 ExpiresByType image/jpg "access plus 2592000 seconds"
 ExpiresByType image/jpeg "access plus 2592000 seconds"
 ExpiresByType image/png "access plus 2592000 seconds"
 ExpiresByType image/gif "access plus 2592000 seconds"
 AddType image/x-icon .ico
 ExpiresByType image/ico "access plus 2592000 seconds"
 ExpiresByType image/icon "access plus 2592000 seconds"
 ExpiresByType image/x-icon "access plus 2592000 seconds"
 ExpiresByType text/css "access plus 2592000 seconds"
 ExpiresByType text/javascript "access plus 2592000 seconds"
 ExpiresByType text/html "access plus 7200 seconds"
 ExpiresByType application/xhtml+xml "access plus 7200 seconds"
 ExpiresByType application/javascript A259200
 ExpiresByType application/x-javascript "access plus 2592000 seconds"
 ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
</ifmodule>
# END Expire headers

But Google PageSpeed always tells me that it is no time limit specified for my images :

Exploitez la mise en cache du navigateur pour les ressources suivantes pouvant être mises en cache :
http://www.maggeek.com/…332e231a03706ea2c500/1432802522index.css (délai d'expiration non spécifié)
http://www.maggeek.com/…3a06813c432386a0bf82b/1432802522index.js (délai d'expiration non spécifié)
http://www.maggeek.com/…89ffed6c16366921d5c6/1432802521index.css (délai d'expiration non spécifié)
http://www.maggeek.com/…fabdde1bf3771e1e12fe/1432802522index.css (délai d'expiration non spécifié)
http://www.maggeek.com/…float-to-top-button/css/img/arrow001.png (délai d'expiration non spécifié)
http://www.maggeek.com/…uploads/2014/12/Intel-e1417382636860.png (délai d'expiration non spécifié)
http://www.maggeek.com/…oads/2014/12/lichtreflex-421101_1920.jpg (délai d'expiration non spécifié)
http://www.maggeek.com/wp-content/uploads/2015/04/AMD.png (délai d'expiration non spécifié)
http://www.maggeek.com/…tent/uploads/2015/04/Geneva-E-Sport2.png (délai d'expiration non spécifié)
http://www.maggeek.com/wp-content/uploads/2015/04/Hubble.jpg (délai d'expiration non spécifié)
http://www.maggeek.com/wp-content/uploads/2015/04/Point-6.png (délai d'expiration non spécifié)
http://www.maggeek.com/…content/uploads/2015/05/Barre-grise1.png (délai d'expiration non spécifié)
http://www.maggeek.com/…ntent/uploads/2015/05/PC-BSD-150x150.jpg (délai d'expiration non spécifié)
http://www.maggeek.com/…ads/2015/05/chromixium-logo1-150x150.png (délai d'expiration non spécifié)
http://www.maggeek.com/wp-content/uploads/2015/05/ibmx519.jpg (délai d'expiration non spécifié)
https://translate.googleapis.com/…ranslate_static/css/translateelement.css (60 minutes)
https://translate.googleapis.com/…ate_static/js/element/26/element_main.js (60 minutes)
https://translate.googleapis.com/translate_static/js/element/main_fr.js (60 minutes)

It is very complicated to make these settings correctly...

I agree - definitely not my area of expertise unfortunately.

Perhaps your hosting will be able to help you further? All of my caching etc.. is dealt with by my server.

This archived topic is closed to new replies.