skip to Main Content

I added following code in .htaccess file of my php project.

<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 application/pdf "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>

But still google analyzer is not marking it as resolved. it is showing (expiration not specified) for every image,css and js.
Do I need to do something else to make it work?

2

Answers


  1. Your configuration seem good.

    mod_expires is enable in your apache configuration ?

    can you provide the result of :

    curl -I http://yourdomain/an_asset.jpg
    

    EDIT :
    I add a non exhaustive list

    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault "now"
        ExpiresByType application/atom+xml "access plus 5 minutes"
        ExpiresByType application/json "access plus 5 minutes"
        ExpiresByType application/javascript "access plus 30 days"
        ExpiresByType application/mac-binhex40 "access plus 1 day"
        ExpiresByType application/msword "access plus 1 day"
        ExpiresByType application/octet-stream "access plus 30 days"
        ExpiresByType application/pdf "access plus 1 day"
        ExpiresByType application/x-cdf "access plus 1 day"
        ExpiresByType application/x-director "access plus 1 day"
        ExpiresByType application/x-font-ttf "access plus 1 day"
        ExpiresByType application/x-font-opentype "access plus 1 day"
        ExpiresByType application/x-font-woff "access plus 1 day"
        ExpiresByType application/x-javascript "access plus 30 days"
        ExpiresByType application/x-netcdf "access plus 1 day"
        ExpiresByType application/x-shockwave-flash "access plus 1 day"
        ExpiresByType application/xhtml+xml "access plus 5 minutes"
        ExpiresByType application/xml "access plus 5 minutes"
        ExpiresByType application/font-woff "access plus 1 day"
        ExpiresByType application/zip "access plus 1 day"
        ExpiresByType application/vnd.ms-fontobject "access plus 30 days"
        ExpiresByType audio/basic "access plus 1 day"
        ExpiresByType audio/mpeg "access plus 1 day"
        ExpiresByType audio/x-aiff "access plus 1 day"
        ExpiresByType audio/x-wav "access plus 1 day"
        ExpiresByType image/bmp "access plus 1 day"
        ExpiresByType image/gif "access plus 1 day"
        ExpiresByType image/jpeg "access plus 1 day"
        ExpiresByType image/png "access plus 1 day"
        ExpiresByType image/svg+xml "access plus 30 days"
        ExpiresByType image/vnd.microsoft.icon "access plus 7 days"
        ExpiresByType image/x-icon "access plus 1 day"
        ExpiresByType text/css "access plus 30 days"
        ExpiresByType text/html "access plus 5 minutes"
        ExpiresByType text/javascript "access plus 30 days"
        ExpiresByType text/plain "access plus 1 day"
        ExpiresByType text/xml "access plus 5 minutes"
        ExpiresByType video/quicktime "access plus 1 day"
        ExpiresByType video/mp4 "access plus 365 days"
        ExpiresByType video/webm "access plus 365 days"
        ExpiresByType video/ogg "access plus 365 days"
        ExpiresByType video/x-msvideo "access plus 1 day"
    </IfModule>
    
    Login or Signup to reply.
  2. compress-php-css-js-javascript-optimize-website-performance

    Just replace “/the/full/path/of/this/file” path to your correct directory by using this php code dirname(__FILE__)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search