Skip to content

Commit 78ad545

Browse files
Make http_cache_forever use immutable: true
1 parent 0d30e84 commit 78ad545

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Make `http_cache_forever` use `immutable: true`
2+
3+
*Nate Matykiewicz*
4+
15
* Add `config.action_dispatch.strict_freshness`.
26

37
When set to `true`, the `ETag` header takes precedence over the `Last-Modified` header when both are present,

actionpack/lib/action_controller/metal/conditional_get.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def expires_now
320320
# user's web browser. To allow proxies to cache the response, set `true` to
321321
# indicate that they can serve the cached response to all users.
322322
def http_cache_forever(public: false)
323-
expires_in 100.years, public: public
323+
expires_in 100.years, public: public, immutable: true
324324

325325
yield if stale?(etag: request.fullpath,
326326
last_modified: Time.new(2011, 1, 1).utc,

actionpack/test/controller/render_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,15 +1021,15 @@ def cache_me_forever
10211021
def test_cache_with_public
10221022
get :cache_me_forever, params: { public: true }
10231023
assert_response :ok
1024-
assert_equal "max-age=#{100.years}, public", @response.headers["Cache-Control"]
1024+
assert_equal "max-age=#{100.years}, public, immutable", @response.headers["Cache-Control"]
10251025
assert_not_nil @response.etag
10261026
assert_predicate @response, :weak_etag?
10271027
end
10281028

10291029
def test_cache_with_private
10301030
get :cache_me_forever
10311031
assert_response :ok
1032-
assert_equal "max-age=#{100.years}, private", @response.headers["Cache-Control"]
1032+
assert_equal "max-age=#{100.years}, private, immutable", @response.headers["Cache-Control"]
10331033
assert_not_nil @response.etag
10341034
assert_predicate @response, :weak_etag?
10351035
end

activestorage/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
* Mark proxied files as `immutable` in their Cache-Control header
2+
3+
*Nate Matykiewicz*
14

25
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/activestorage/CHANGELOG.md) for previous changes.

activestorage/test/controllers/blobs/proxy_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ActiveStorage::Blobs::ProxyControllerTest < ActionDispatch::IntegrationTes
1313
test "HTTP caching" do
1414
get rails_storage_proxy_url(create_file_blob(filename: "racecar.jpg"))
1515
assert_response :success
16-
assert_equal "max-age=3155695200, public", response.headers["Cache-Control"]
16+
assert_equal "max-age=3155695200, public, immutable", response.headers["Cache-Control"]
1717
end
1818

1919
test "invalidates cache and returns a 404 if the file is not found on download" do

0 commit comments

Comments
 (0)