Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Extract AP Page and Action caching from Rails #7833

Merged
merged 4 commits into from

7 participants

@frodsan

This functionality will be available from actionpack-deprecated_caching gem.
The gem is currently hosted at https://github.com/frodsan/actionpack-deprecated_caching.

pd: I'm not sure about the name.

@steveklabnik
Collaborator

:shipit:

@sikachu
Collaborator

:shipit:

@rafaelfranca rafaelfranca commented on the diff
actionpack/test/controller/caching_test.rb
((27 lines not shown))
def setup
- FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
- FileUtils.mkdir_p(FILE_STORE_PATH)
- end
-
- def teardown
- FileUtils.rm_rf(File.dirname(FILE_STORE_PATH))
+ super
+ @store = ActiveSupport::Cache::MemoryStore.new
+ @controller = FragmentCachingMetalTestController.new
@rafaelfranca Owner

Do we need all this setup?

@rafaelfranca Owner

Right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
actionpack/lib/action_controller/caching.rb
((6 lines not shown))
include Sweeping if defined?(ActiveRecord)
included do
extend ConfigMethods
+ # Most Rails requests do not have an extension, such as <tt>/weblog/new</tt>.
+ # In these cases, the page caching mechanism will add one in order to make it
+ # easy for the cached files to be picked up properly by the web server. By
+ # default, this cache extension is <tt>.html</tt>. If you want something else,
+ # like <tt>.php</tt> or <tt>.shtml</tt>, just set Base.page_cache_extension.
+ # In cases where a request already has an extension, such as <tt>.xml</tt>
+ # or <tt>.rss</tt>, page caching will not add an extension. This allows it
+ # to work well with RESTful apps.
+ config_accessor :page_cache_extension
@rafaelfranca Owner

I think is better to rename this to default_static_extension

@frodsan
frodsan added a note

Ok, I'll ping you when it's done. Thanks <3!

@rafaelfranca Owner

We will need to add backward compatibility to page_cache_extension and deprecate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@andrewle

I'd like to understand the motivations behind moving this out of rails core. I had a brief exchange with @steveklabnik and understand that maybe developers should just be using Rack::Cache/Varnish + proper HTTP caching headers, but action caching also allows you hit your middleware and filter stack, which is useful for authentication.

I'm all for moving page caching out though, as it bypasses the Rails stack altogether.

@dhh
Owner
dhh commented

Action caching relies on old-school manual expiration. No bueno. Much better to control your cache using key-based view and possibly controller based caches.

You're still free to use this through the plugin, but it's not a good fit for core any more. The state of the art moved on.

@rafaelfranca
Owner

@frodsan lets move this forward.

Please add a CHANGELOG entry and update the upgrading guide talking about the removal and pointing to the plugin.

@rafaelfranca rafaelfranca merged commit b0a7068 into rails:master
@sgerrand sgerrand referenced this pull request from a commit in sgerrand/rails
@jroes jroes Refer to 37signals blog post for alternative
According to the rationale at rails#7833 (comment), we should recommend new users to follow DHH's approach outlined at http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works.

This is the first step, and perhaps in the future we can write some specific recommendations out.
56cdf78
@benja83 benja83 referenced this pull request from a commit in benja83/toyotakataboard-relational
@benja83 benja83