Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:53:35+00:00 2026-05-25T20:53:35+00:00

When running the assets:precompile rake task, gzipped versions of your app’s assets are created.

  • 0

When running the assets:precompile rake task, gzipped versions of your app’s assets are created. According to the Rails guide for the asset pipeline, you can configure your web server (in my case Apache 2.2) to serve these precompressed files instead of having the web server do the work.

What I can’t figure out is how to get mod_deflate configured so that these files are served instead of being double-compressed and then served?

I have mod_deflate enabled via httpd.conf:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

And I’ve converted the code on the rails guide to go into the .htaccess in public/assets:

# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.

Header unset Last-Modified
Header unset ETag
FileETag None

# RFC says only cache for 1 year

ExpiresActive On
ExpiresDefault "access plus 1 year"

# Serve gzipped versions instead of requiring Apache to do the work

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.+) $1.gz [L]

# without it, Content-Type will be "application/x-gzip"

<FilesMatch .*\.css.gz>
    ForceType text/css
</FilesMatch>

<FilesMatch .*\.js.gz>
    ForceType text/javascript
</FilesMatch>

Any ideas how to set this up properly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:53:36+00:00Added an answer on May 25, 2026 at 8:53 pm

    First, you don’t want mod_deflate to operate here. So in your assets .htaccess file add:

    SetEnv no-gzip
    

    This should turn off mod_deflate for your assets.

    Second, I hate to disagree with the rails folks, but I think there are a couple deficiencies in their assets .htaccess recipe. The top part is fine but for RewriteEngine and beyond I’d have:

    RewriteEngine on
    # Make sure the browser supports gzip encoding before we send it
    RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b
    RewriteCond %{REQUEST_URI} .*\.(css|js)
    RewriteCond %{REQUEST_FILENAME}.gz -s
    RewriteRule ^(.+) $1.gz [L]
    
    # without it, Content-Type will be "application/x-gzip"
    # also add a content-encoding header to tell the browser to decompress
    
    <FilesMatch \.css\.gz$>
        ForceType text/css
        Header set Content-Encoding gzip
    </FilesMatch>
    
    <FilesMatch \.js\.gz$>
        ForceType application/javascript
        Header set Content-Encoding gzip
    </FilesMatch>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When running: rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets Everything precompiles but not my /app/assets/images/* I even
I'm getting this error when I push to Heroku: Running: rake assets:precompile rake aborted!
I'm running a rails 3.1 app on Heroku Cedar stack which supports the asset
I'm unable to get rake precompile tasks running with Rails 3.1.3. I get the
app/assets/stylesheets/application.css *= require formtastic I get this error: rake assets:precompile /Users/Nerian/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby /Users/Nerian/.rvm/gems/ruby-1.9.3-rc1@davinci/bin/rake assets:precompile:all RAILS_ENV=production
Since I'm running my app on the Bamboo stack I'm precompiling my assets and
EDIT This question should be: Why is rails_admin causing rake asset:precompile to fail? I'm
I am trying to precompile assets ( rake assets:precompile or bundle exec rake assets:precompile
I'm trying to precompile assets: Gemfile: source 'https://rubygems.org' gem 'rails', '~> 3.2.1' # Bundle
$ rake assets:precompile rake aborted! could not connect to server: Network is unreachable Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.