FEATURE: Normalize the service worker route (#8359)

* FEATURE: Normalize the service worker route

Update cache headers so they are not immutable outside of the rails app

Add the ability to purge the service worker cache from localhost

Rails -> nginx will pass immutable flags so the file is cached until reloaded.
In most cases, nginx will have its cache flushed on rebuild (new image)

For those needing dynamic re-caching (such as upgrading via the UI),
a rake task for flushing the service worker script is provided
through `assets:flush_sw`
This commit is contained in:
Jeff Wong
2019-11-20 11:33:41 -08:00
committed by GitHub
parent 797045f5a9
commit 9799a651b6
4 changed files with 31 additions and 4 deletions

View File

@@ -456,8 +456,6 @@ module ApplicationHelper
end
def client_side_setup_data
service_worker_url = Rails.env.development? ? 'service-worker.js' : Rails.application.assets_manifest.assets['service-worker.js']
setup_data = {
cdn: Rails.configuration.action_controller.asset_host,
base_url: Discourse.base_url,
@@ -465,7 +463,7 @@ module ApplicationHelper
environment: Rails.env,
letter_avatar_version: LetterAvatar.version,
markdown_it_url: script_asset_path('markdown-it-bundle'),
service_worker_url: service_worker_url,
service_worker_url: 'service-worker.js',
default_locale: SiteSetting.default_locale,
asset_version: Discourse.assets_digest,
disable_custom_css: loading_admin?,