Questions tagged [action-caching]

21 questions
12
votes
1 answer

Rails caches_action is skipping before_filters

I have a controller in which I am caching the show action. The show action has a number of before filters for security that are meant to execute and redirect if the user is not logged in, not a member of the current group etc. These before filters…
James P McGrath
  • 1,856
  • 1
  • 20
  • 35
11
votes
4 answers

format.js is not manipulating dom once action caching enabled

Note: I am presenting a logic here what I am doing. What I am doing: Think about the basic index action where we are listing products and with pagination. Now using remote-true option I have enabled ajax based pagination. So far things works…
Mohit Jain
  • 43,139
  • 57
  • 169
  • 274
10
votes
2 answers

How to cache render :json

I have a controller index action which returns json output. render :json => my_array.to_json What type of caching do I have to use here. Does 'page caching' make sense for this. Or do I have to do action caching like below caches_action :index
user290870
  • 1,591
  • 3
  • 19
  • 27
8
votes
2 answers

Expire action cache with custom cache_path

I'm having some problem expiring an action cache in my application. Here is my controller: class ToplistsController < ApplicationController caches_action :songs, cache_path: :custom_cache_path.to_proc def custom_cache_path …
Linus Oleander
  • 17,746
  • 15
  • 69
  • 102
6
votes
1 answer

Heroku action caching doesn't seem to work

I have been playing around with different caching strategies on Heroku and have add their memcached add-on with an aim to add action caching to my app. When I view Rails.cache.stats on my current app however (with memcached installed and using the…
seadowg
  • 4,215
  • 6
  • 35
  • 43
6
votes
2 answers

Rails Action Caching for user specific records

I am a rails newbie trying to implement caching for my app. I installed memcached and configured it in my development.rb as follows: config.action_controller.perform_caching = true config.cache_store = :mem_cache_store I have a…
truthSeekr
  • 1,603
  • 4
  • 25
  • 44
5
votes
2 answers

Rails action caching RSpec test fails

I have a spec that tests action caching when caching is disabled and when caching is enabled. It seems like the order of test execution affects whether they pass or not. it "should not cache the index page when we're not caching" do …
Thomas
  • 157
  • 1
  • 8
3
votes
1 answer

rails3 caching: expire_action with parameters cached by caches_action(GET)

I'm working on a search feature that when typing something make an ajax call to get the results. I wanna caches the search action with search keywords in memory_cache, so i make it like this: # caches_action with GET parameters caches_action…
ifyouseewendy
  • 6,674
  • 1
  • 21
  • 26
3
votes
1 answer

Why do cache sweepers need to be declared in controllers?

A cache sweeper is an observer with some hooks on the model it is observing: class MySweeper < ActionController::Caching::Sweeper observe MyModel def after_update(my_model) expire_page(...) end end But documentation and guides also say…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
2
votes
2 answers

Set caches_action, :expires_in => dynamically

Every example of caches_action I've seen looks like: caches_action, :expires_in => 5.minutes but I'd like to set expires_in based on the expiration time of an object used in the action. Is there any way to reference that object when setting…
swrobel
  • 4,053
  • 2
  • 33
  • 42
2
votes
1 answer

Rails 3 caching: How do I use a sweeper with Action and Fragment caching to expire the cache?

I'm working on a page that displays a restaurant menu. I have 2 models: FoodMenu has_many :products and Product belongs_to :food_menu. I don't have controllers for either model. Instead, I am using a "pages_controller.rb" to display each FoodMenu…
monfresh
  • 7,974
  • 1
  • 25
  • 22
2
votes
1 answer

How to expire Action Cache when underlying model is updated in Rails 6?

I am using Action Caching which seems to work OK with Rails 6. The issue is how to expire the cache when the underlying model is updated? According to Rails Guides See the actionpack-action_caching gem. See DHH's key-based cache expiration overview…
B Seven
  • 44,484
  • 66
  • 240
  • 385
2
votes
1 answer

Rails action caching refresh after expire

I'm looking to expire and then refresh the cache for a controller action using a publicly accessible endpoint. In my app currently, /all returns cached json, and /update expires the cache. You can see the existing relevant code below. What I'd like…
manderson
  • 98
  • 13
2
votes
1 answer

Unable to expire_action on Rails

tl;dr My expire_index method below is getting called, I see the puts in the logs. However, when I refresh the page is the stale version. note: I am using rails_admin for updating the models. But have also noticed the same behavior using rails…
1
vote
1 answer

Rails action caching question

I'm not quite sure how to ensure my caching is working, but I'm pretty sure it's not. I have a users controller with an index action that I'm action caching until a new user is created. Here's the code: UsersController < ApplicationController …
brad
  • 31,987
  • 28
  • 102
  • 155
1
2