Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
Created July 9, 2024 19:48
Show Gist options
  • Select an option

  • Save julianrubisch/9fc865ac94f52c54ae26cc68f0db7b7d to your computer and use it in GitHub Desktop.

Select an option

Save julianrubisch/9fc865ac94f52c54ae26cc68f0db7b7d to your computer and use it in GitHub Desktop.

Revisions

  1. julianrubisch created this gist Jul 9, 2024.
    13 changes: 13 additions & 0 deletions sitepress_cache.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    Rails.application.config.after_initialize do
    Sitepress::SiteController.include(Sitepress::HttpCaching)
    end

    module Sitepress::HttpCaching
    extend ActiveSupport::Concern

    included do
    before_action do
    fresh_when current_resource.asset.updated_at if !!current_resource.data["cache"]
    end
    end
    end