I am learning to improve Drupal's performance and I discovered Google's PageSpeed Insights tool. It urges me to use browser caching and presents me a list of all my images at mytheme/images and default/files. To be honest, I am not too sure about what this means. I assumed that Drupal's default caching could handle this, but apparently that is not the case, since caching is already enabled at Performance (both minimal lifetime and expiration time are set to 1 hour).

How can I cache all those images as well? Should I install some extra modules like Varnish or Boost to solve this? As a beginner, I can't really wrap my head around all these performance modules and what they do.


Images are directly served by the web server. You need to configure your web server to server images (and other files) with the appropriate headers. On Apache HTTP server, this is usually done with the mod_expires module.

  • Google page speed is looking for 1 month or more for the cache-control header. You can edit your .htaccess file and change ExpiresDefault A1209600 to ExpiresDefault A2628000. It should be around line 45 – mikeytown2 Sep 7 '16 at 22:29
  • Thank you for your hint; I gave you an upvote. I contacted my server host about this and they solved it for me (see the accepted answer). – Jeroen Sep 9 '16 at 21:17

After Pierre Buyle's answer, I contacted my server host about this problem and they solved it by adding the following code to my .htaccess file:

# Cache Control Settings
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=1333600, public"
<FilesMatch ".(xml|txt)$">
Header set Cache-Control "max-age=1333600, public, must-revalidate"
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=1333600, must-revalidate"

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.