Skip to content

A platform for community discussion. Free, open, simple.

PERF: cache service worker for 1 hour

Sam5ad1709dbaa2
diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb
index 701644c7b63..993200edb3f 100644
--- a/app/controllers/static_controller.rb
+++ b/app/controllers/static_controller.rb
@@ -147,6 +147,10 @@ class StaticController < ApplicationController
def service_worker_asset
respond_to do |format|
format.js do
+
+ # we take 1 hour to give a new service worker to all users
+ immutable_for 1.hour
+
render(
plain: Rails.application.assets_manifest.find_sources('service-worker.js').first,
content_type: 'application/javascript'