Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11184 (new defect)

Opened 5 months ago

Last modified 3 months ago

[PATCH] Improve ActionCaching's format-handling

Reported by: Catfish Assigned to: bitsweat
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc:

Description

ActionCaching seems a little confused about formats. a) It ignores HTTP_ACCEPT formats, instead relying just on the path extension b) When expiring caches, it uses the extension from the request. If I POST to create a new record, both xml & html versions of that resource are going to need invalidating, so it doesn't make sense to vary what you're expiring based on whether the request came in via xml or html

This patch messes around with the ActionCache code so that ActionCachePath no longer infers extensions from the request while expiring actions, and makes it aware of request.format when it does try to produce an extension.

Attachments

caching_extensions.diff (6.4 kB) - added by Catfish on 02/21/08 16:25:30.
0001-Improve-ActionCaching-s-format-handling.patch (6.5 kB) - added by Catfish on 06/01/08 00:17:56.

Change History

02/21/08 16:25:30 changed by Catfish

  • attachment caching_extensions.diff added.

03/03/08 07:02:07 changed by nzkoz

  • owner changed from core to bitsweat.

You guys do caching and formats don't you?

03/03/08 10:45:09 changed by Catfish

Just FWIW, we've been running this in production for a while without problems, but obviously it does change behaviour. The main changes are -

- changing the cache filename. Before this patch you'd often end up with index.xml.xml.cache, it's now simply index.xml.cache. index.all.cache might also appear for html caching, depending on your Accept header.

- making the format explicit when expiring actions. Before this patch, if you posted an xml request that ended up doing expire_action :controller => 'foo', :action => 'bar', you'd end up deleting the xml cache. If you posted the same request through html, you'd delete the html cache. So anyone relying on that to delete the right cache might be caught out by this change, but I'm struggling to think of cases where you really want to only expire a specific format based on what format the original request came in by. Personally I always end up explicitly expiring html, xml, & js, all at the same time.

(Which reminds me, expire_action :controller => 'foo', :action => 'bar', :format => '*' might be handy. If & when this patch is accepted, I'll see if I can add another patch for it)

03/06/08 11:59:59 changed by Catfish

Just because I wanted an excuse to try github, you can pull this patch from http://github.com/jdelStrother/rails/tree/caching, if you swing that way.

03/10/08 09:23:30 changed by Catfish

... except that's (one of) the unofficial rails mirrors. For the semi-official version, try http://github.com/jdelStrother/koz-rails/tree/caching

04/09/08 13:54:05 changed by yaroslav

+1

04/11/08 14:35:09 changed by Catfish

... and because koz-rails and the official rails repo don't merge nicely, here's yet another - http://github.com/jdelStrother/rails/tree/caching

Hopefully that's the last of them.

04/12/08 03:59:35 changed by nzkoz

The commit message should probably be written in a changelog-friendly way rather than a submission-oriented way. Looks good apart from that though.

04/12/08 08:40:55 changed by Catfish

I've updated http://github.com/jdelStrother/rails/tree/caching with a new commit message

06/01/08 00:17:56 changed by Catfish

  • attachment 0001-Improve-ActionCaching-s-format-handling.patch added.