From 3925e92757ed5c44039846769d0590fde72417fd Mon Sep 17 00:00:00 2001
From: Felix Eckhofer <felix@eckhofer.com>
Date: Sat, 21 Dec 2024 04:12:23 +0100
Subject: [PATCH] Add cache control headers for assets

---
 config/environments/production.rb | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/config/environments/production.rb b/config/environments/production.rb
index ca7a203..629f0a3 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -23,6 +23,12 @@ Rails.application.configure do
   # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
   # config.public_file_server.enabled = false
 
+  # Set cache headers for static files
+  config.public_file_server.headers = {
+    'Cache-Control' => 'public, max-age=31536000',
+    'Expires' => 1.year.from_now.to_formatted_s(:rfc822)
+  }
+
   # Compress CSS using a preprocessor.
   # config.assets.css_compressor = :sass
 
-- 
GitLab