Skip to content

Commit

Permalink
Merge pull request #48869 from brunoprietog/disable-session-active-st…
Browse files Browse the repository at this point in the history
…orage-proxy-controllers

Disable session in ActiveStorage blobs and representations proxy controllers
  • Loading branch information
rafaelfranca committed Aug 3, 2023
2 parents fbaba19 + 379e3b4 commit 83e5988
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions activestorage/CHANGELOG.md
@@ -1,3 +1,11 @@
* Disables the session in `ActiveStorage::Blobs::ProxyController`
and `ActiveStorage::Representations::ProxyController`
in order to allow caching by default in some CDNs as CloudFlare

Fixes #44136

*Bruno Prieto*

* Add `tags` to `ActiveStorage::Analyzer::AudioAnalyzer` output

*Keaton Roux*
Expand Down
Expand Up @@ -9,6 +9,7 @@
class ActiveStorage::Blobs::ProxyController < ActiveStorage::BaseController
include ActiveStorage::SetBlob
include ActiveStorage::Streaming
include ActiveStorage::DisableSession

def show
if request.headers["Range"].present?
Expand Down
Expand Up @@ -8,6 +8,7 @@
# {Authenticated Controllers}[https://guides.rubyonrails.org/active_storage_overview.html#authenticated-controllers].
class ActiveStorage::Representations::ProxyController < ActiveStorage::Representations::BaseController
include ActiveStorage::Streaming
include ActiveStorage::DisableSession

def show
http_cache_forever public: true do
Expand Down
@@ -0,0 +1,12 @@
# frozen_string_literal: true

# This concern disables the session in order to allow caching by default in some CDNs as CloudFlare.
module ActiveStorage::DisableSession
extend ActiveSupport::Concern

included do
before_action do
request.session_options[:skip] = true
end
end
end

0 comments on commit 83e5988

Please sign in to comment.