From 802e81f8551e10a3f97846a49636e675c7e21cb3 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 13 Jul 2026 23:29:54 +0200 Subject: Add cache-buster using mtime of css and js files outside the asset pipeline --- app/helpers/admin_helper.rb | 6 ++++++ app/views/layouts/admin.html.erb | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 08336ef..1e84620 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -8,4 +8,10 @@ module AdminHelper link_to raw('English'), url_for(params.permit(:locale, :page_path).to_h.merge('locale' => 'de')) end end + + def mtime_busted_path(path) + file = Rails.public_path.join(path.sub(%r{\A/}, "")) + raise "Static asset not found for cache-busting: #{path} (looked for #{file})" unless File.exist?(file) + "#{path}?v=#{File.mtime(file).to_i}" + end end diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 8bbc0d5..0856a0f 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -10,10 +10,10 @@ <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> <%= javascript_include_tag 'admin_bundle' %> <%= tinymce_assets %> - - - - + + + +