Skip to content

Encapsulate stale_when_importmap_changes method#284

Merged
dhh merged 2 commits intomainfrom
stale-when-importmap-changes
Dec 21, 2024
Merged

Encapsulate stale_when_importmap_changes method#284
dhh merged 2 commits intomainfrom
stale-when-importmap-changes

Conversation

@dhh
Copy link
Copy Markdown
Member

@dhh dhh commented Dec 20, 2024

Most Rails applications use etags to some extent. We should therefore make it the default to include the importmap digest in that calculation on HTML requests. So we turn:

class ApplicationController < ActionController::Base
  etag { Rails.application.importmap.digest(resolver: helpers) if request.format&.html? }
end

...into:

class ApplicationController < ActionController::Base
  stale_when_importmap_changes
end

And we can add that add that to be part of the default ApplicationController in Rails when using import maps.

@dhh dhh merged commit 2ef81f0 into main Dec 21, 2024
@rafaelfranca rafaelfranca deleted the stale-when-importmap-changes branch January 7, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant