Skip to content

Commit

Permalink
Add caching headers for production assets (#1087)
Browse files Browse the repository at this point in the history
It turns out we weren't sending any caching headers for assets in production, so they weren't generally getting cached. This adds a 1-day cache for them (most assets are compiled and have hashes in the name, so could be cached forever, but some don't, e.g. `robots.txt`).
  • Loading branch information
Mr0grog authored Feb 9, 2023
1 parent 963b431 commit 81f440b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.headers = { 'Cache-Control' => "public, max-age=#{1.day.to_i}" }

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
Expand Down

0 comments on commit 81f440b

Please sign in to comment.