1

I've enabled gzip for by Ruby on Rails application using webpack

After asset:precompile, I can see gzipped assets in my public folder.

This is my configuration for Apache, where I'm asking it to serve gzip assets when available -

 <LocationMatch "^/assets/.*$">
    Header unset ETag
    FileETag None
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
    Header merge Cache-Control public
    Header unset Set-Cookie
    SetEnv no-gzip
  </LocationMatch>

  RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b
  RewriteCond /path/to/app/public%{REQUEST_FILENAME}.gz -s
  RewriteRule ^(.+) $1.gz [L]

  <FilesMatch \.css\.gz$>
    ForceType text/css
    Header set Content-Encoding gzip
  </FilesMatch>

But then, when I'm loading the app from the browser, it seems as though the browser is trying to evaluate the gzipped javascript file as is without performing decompression.

Preview of a gzipped JS file from the browser console

Response Headers

Am I doing something wrong with the configuration in Apache?

Steve Robinson
  • 3,759
  • 3
  • 36
  • 57

0 Answers0