Skip to content

Commit

Permalink
Merge pull request rails#48869 from brunoprietog/disable-session-acti…
Browse files Browse the repository at this point in the history
…ve-storage-proxy-controllers

Disable session in ActiveStorage blobs and representations proxy controllers
  • Loading branch information
rafaelfranca authored 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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.