skip to Main Content

I’m investigating my website on GTmetrix and currently I’m working on this case:

enter image description here

To make it working, I’ve added this to the .htaccess file which is located on the root of my project:

<IfModule mod_expires.c>
  ExpiresActive on

# Your document html
  ExpiresByType text/html "access plus 0 seconds"

# 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/javascript "access plus 1 year"
  ExpiresByType text/css "access plus 1 year"
</IfModule>

But still GTmetrix gives a score of zero to this case of my website. Noted that my website uses Linux ubuntu 16.04 OS an appache web server.

Any idea how can I do that?

2

Answers


  1. Chosen as BEST ANSWER

    I did it using following commands:

    sudo apt-get update
    sudo apt-get install apache2-utils
    sudo a2enmod cache
    sudo a2enmod cache_disk
    sudo a2enmod expires
    sudo a2enmod headers
    sudo service apache2 restart
    

  2. I am using following code, and it’s working perfect for me:

    # Add Expire headers
    <IfModule mod_expires.c>
    <Filesmatch ".(jpg|jpeg|png|gif|js|css|swf|ico|woff|mp3)$">
      ExpiresActive on
      ExpiresDefault "access plus 30 days"
    </Filesmatch>
    </IfModule>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search