-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delivering assets through CloudFlare requires monkey-patch #44136
Comments
This is mostly a feature request, so I think you either should implement it or start a thread on Rails Core discussion board to see if anyone is interested in implement it. |
How rude. |
An alternative to monkey patching is to use one of the limited page rules that comes with free plans to force cloudflare to cache:
|
4 tasks
paulreece
pushed a commit
to paulreece/rails-paulreece
that referenced
this issue
Aug 26, 2023
…roller This allows CDNs such as CloudFlare to cache files delivered by proxy by default Fix rails#44136
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
It appears that delivering ActiveStorage assets through CloudFlare (free plan) can be done as suggested here + here:
Rails.application.config.active_storage.resolve_model_to_route = :rails_storage_proxy
toconfig/initializers/active_storage.rb
OR userails_storage_proxy_path
in the views (e.g.rails_storage_proxy_path(content.poster.variant(resize_to_limit: [size, size]))
). There is it seems no need to define adirect :cdn_image
like in the docs, as the CDN host remains the same when using CloudFlare.request.session_options[:skip] = true
in theProxyController
s (ref)Expected behavior
Actual behavior
After doing the above, I can see my images have headers
cache-control: public, max-age=3155695200
andcf-cache-status: HIT
(after the second request). However, a monkey-patch was necessary to achieve this, so @zzak recommended I open this issue.System configuration
Rails version: 7.0.0
Ruby version: 3.0.3
The text was updated successfully, but these errors were encountered: