Skip to content
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

action caching keys don't change when template changes #124

Closed
jjb opened this issue Jan 6, 2014 · 5 comments
Closed

action caching keys don't change when template changes #124

jjb opened this issue Jan 6, 2014 · 5 comments

Comments

@jjb
Copy link
Contributor

jjb commented Jan 6, 2014

Hi, I'm @jjb. You might know me from commits such as ability to specify that layout should not be cached. I recently discovered/realized that whatever rails uses for its cache key does not change if the template involved changed. I did a cursory search for best practices for bumping this key and couldn't find anything.

If such a method exists, we should try to implement it within high_voltage.

If not, then we should probably deprecate action_caching.

my current solution is to turn off action caching and simply put

- cache do
    .content
      # ...

at the top of every single page.

pros:

  • automagic, complete solution, supported by rails
  • zero configuration
  • action caching is no longer supported within rails, only by a gem. and the gem is only going to be maintained through rails 4.1

cons:

  • entire template has to have an additional indentation
  • developers have to remember to do this for every template

these cons are well worth it to me, especially for the small number of static pages that I use high_voltage for.

so, actions/questions:

  1. is there a simple way that we can implement action caching key bumping when the template is bumped? if so, we may as well do it -- rails 4.1 will be around for quite a while so this is a fine thing to support.
  2. if we abandon action caching, is there a more elegant way to support template caching without making the user put a big - cache at the top of every template?
@harlow
Copy link
Contributor

harlow commented Jan 6, 2014

@jjb great to hear from you.

I agree that having - cache do in views is not ideal. However, if the ActionCaching is going to no longer be maintained I think my vote may be to remove entirely. Will need to think about the consequences of this for Apps using pervious versions of the High Voltage gem.

There is an article here that will invalidate the cache on each deploy:
http://ninjasandrobots.com/how-to-bust-your-rails-etag-cache-on-deployment

That could be one way to go about it.

@jjb
Copy link
Contributor Author

jjb commented Jan 7, 2014

I don't want to bust all etags for all resources in the app every time i deploy -- i'll soon have thousands of daily users and be deploying multiple times a day.

i guess for smaller sites that is a good option.

@harlow
Copy link
Contributor

harlow commented Jul 19, 2014

@jjb since we're deprecated the ActionCaching in High Voltage I'm going to close this issue.

If you are getting tons of traffic on mostly static pages I'd suggest checking out Varnish. Its a reverse-proxy that sits in front of your rails app. Here is a quick overview: http://www.hward.com/scale-rails-with-varnish-http-caching-layer

@harlow harlow closed this as completed Jul 19, 2014
@jjb
Copy link
Contributor Author

jjb commented Jul 20, 2014

sounds good. just to be clear -- varnish (and rack cache and friends) requires http caching, which requires sending optimal headers when serving high_voltage pages. does high_voltage support this directly or would one have to manually code it into a custom controller?

@harlow
Copy link
Contributor

harlow commented Jul 20, 2014

@jjb it would need a custom controller. Could def be in interesting idea to build that in as a config option to the initializer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants