title: leverage browser caching .htaccess not working
body: <p>I am using laravel 5, for speed I test in google speed insight, its showing leverage browser caching</p>
  
  <p>to solve that I have used following .htaccess code but non of them are working</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  
  RewriteRule ^(.*)$ public/$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_headers.c&gt;
  # Serve gzip compressed CSS files if they exist 
  # and the client accepts gzip.
  RewriteCond "%{HTTP:Accept-encoding}" "gzip"
  RewriteCond "%{REQUEST_FILENAME}\.gz" -s
  RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA]
  
  # Serve gzip compressed JS files if they exist 
  # and the client accepts gzip.
  RewriteCond "%{HTTP:Accept-encoding}" "gzip"
  RewriteCond "%{REQUEST_FILENAME}\.gz" -s
  RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA]
  
  
  # Serve correct content types, and prevent mod_deflate double gzip.
  RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
  RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
  
  
  &lt;FilesMatch "(\.js\.gz|\.css\.gz)$"&gt;
    # Serve correct encoding type.
    Header append Content-Encoding gzip
  
    # Force proxies to cache gzipped &amp; 
    # non-gzipped css/js files separately.
    Header append Vary Accept-Encoding
  &lt;/FilesMatch&gt;
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_expires.c&gt;
  ExpiresActive on
  
  # Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault "access plus 1 month"
  
  # Media: images, video, audio
  ExpiresByType assets/images "access plus 1 month" 
  
  # CSS and JavaScript
  ExpiresByType assets/css "access plus 1 month"
  ExpiresByType assets/js "access plus 1 month"
  
  &lt;IfModule mod_headers.c&gt;
   Header append Cache-Control "public"
  &lt;/IfModule&gt;
  
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Second code that I used in .htaccess is this one</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  
  RewriteRule ^(.*)$ public/$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?params=$1 [L,QSA]
  &lt;/IfModule&gt;
  &lt;IfModule mod_expires.c&gt;
  ExpiresActive On
  ExpiresDefault "access plus 1 year"
  ExpiresByType text/html "access plus 1 second"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType image/x-icon "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 604800 seconds"
  ExpiresByType text/javascript "access plus 604800 seconds"
  ExpiresByType application/x-javascript "access plus 604800 seconds"
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>I also tried this one code in .htaccess to make it work, but this one is also not working </p>
  
  <pre><code>&lt;IfModule mod_expires.c&gt;
  # Set Cache-Control and Expires headers
  &lt;filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$"&gt;
  Header set Cache-Control "max-age=2592000, public"
  Header set Expires "1 day"
  &lt;/filesMatch&gt;
  &lt;filesMatch "\\.(css|css.gz)$"&gt;
  Header set Cache-Control "max-age=604800, public"
  &lt;/filesMatch&gt;
  &lt;filesMatch "\\.(js|js.gz)$"&gt;
  Header set Cache-Control "max-age=604800, public"
  &lt;/filesMatch&gt;
  &lt;filesMatch "\\.(xml|txt)$"&gt;
  Header set Cache-Control "max-age=216000, public, must-revalidate"
  &lt;/filesMatch&gt;
  &lt;filesMatch "\\.(html|htm)$"&gt;
  Header set Cache-Control "max-age=7200, public, must-revalidate"
  &lt;/filesMatch&gt;
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>I have used all above code but I got same result every time
  should fix: Leverage browser caching</p>
  
  <p>on most of the anaylser.</p>
  
  <p>is anything I am missing in this</p>