Skip to content

Commit 94e3d75

Browse files
committed
twir-2025-05-16
1 parent 899e5af commit 94e3d75

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
layout: post
3+
title: "RFC-9111 style Cache-Control directives hit or miss"
4+
categories: news
5+
author: zzak
6+
og_image: assets/images/this-week-in-rails.png
7+
published: true
8+
date: 2025-05-16
9+
---
10+
11+
12+
Hi, it's [zzak](https://github.com/zzak). Let's explore this week's changes in the Rails codebase.
13+
14+
**Message from the Rails Foundation**
15+
While Rails World sold out quickly this year, a friendly reminder that the sessions will be recorded and published on YouTube quickly- the Opening and Closing Keynotes immediately, with all other sessions published shortly thereafter.
16+
If you didn’t manage to get a ticket, this is a fantastic opportunity to check out some of the other Ruby events taking place this year: <https://rubyconferences.org/>
17+
18+
[Add ActiveRecord::Result#affected_rows](https://github.com/rails/rails/pull/55060)
19+
The result returned from calling [exec_query](https://edgeapi.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/DatabaseStatements.html#method-i-exec_query) now provides a method to get the number of affected rows.
20+
21+
```ruby
22+
# Get the number of rows affected by the query:
23+
result = ActiveRecord::Base.lease_connection.exec_query <<~SQL.squish
24+
INSERT INTO posts (title, body)
25+
VALUES ("title_1", "body_1"), ("title_2", "body_2")
26+
SQL
27+
result.affected_rows
28+
# => 2
29+
```
30+
31+
[Drop vendored Trix files in favor of the "action_text-trix" gem](https://github.com/rails/rails/pull/55058)
32+
This change shouldn't have affect on applications, but makes maintenance easier for the Rails team.
33+
Meaning that bug fixes or security patches to Trix no longer have to wait for a Rails release to be available for application developers.
34+
35+
[Bump Trix to v2.1.15](https://github.com/rails/rails/pull/55046)
36+
Speaking of which, [CVE-2025-46812](https://github.com/advisories/GHSA-mcrw-746g-9q8h) was fixed in the latest release of Trix. Please update your applications as soon as possible.
37+
38+
[Only load from CGI when required for Ruby 3.5](https://github.com/rails/rails/pull/55037)
39+
By [retiring CGI](https://bugs.ruby-lang.org/issues/21258) from Ruby's Standard Library of bundled gems, Rails was updated to load the `cgi/escape` which is still supported without emitting warnings from the other parts of the gem.
40+
41+
[Add support for Cache-Control request directives](https://github.com/rails/rails/pull/55033)
42+
This PR adds support for various cache control directives in requests to control how caching is handled by the HTTP client.
43+
Based on [RFC-9111](https://www.rfc-editor.org/rfc/rfc9111.html#name-request-directives) which details strategies for `max-age`, `max-stale`, `min-fresh`, and `no-cache`.
44+
45+
```ruby
46+
def show
47+
if request.cache_control_directives.only_if_cached?
48+
@article = Article.find_cached(params[:id])
49+
return head(:gateway_timeout) if @article.nil?
50+
else
51+
@article = Article.find(params[:id])
52+
end
53+
render :show
54+
end
55+
```
56+
57+
58+
_You can view the whole list of changes [here](https://github.com/rails/rails/compare/@%7B2025-05-09%7D...main@%7B2025-05-16%7D)._
59+
_We had [22 contributors](https://contributors.rubyonrails.org/contributors/in-time-window/20250509-20250516) to the Rails codebase this past week!_
60+
61+
Until next time!
62+
63+
_[Subscribe](https://world.hey.com/this.week.in.rails) to get these updates mailed to you._

0 commit comments

Comments
 (0)