Questions tagged [fragment-caching]

74 questions
2
votes
3 answers

How to handle key based expiration of collections if there is no parent model in Rails 4.0?

Since action and page caches and sweepers will be removed from Rails 4.0, I started to use cache_digests in my Rails 3.2 application, since I'm suffering from this whole manual expiration nightmare. But even after reading some tutorials (How…
Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329
1
vote
2 answers

How do I avoid constantly re-calculating summary data using Rails?

I have a user profile page that has a sidebar with user stats like not unlike the Stack Overflow profile page (e.g., total visits, number of badges). The trouble is that currently I'm hitting the database and calculating these stats with every…
Finch
  • 1,741
  • 3
  • 15
  • 15
1
vote
1 answer

Does Rails' fragment caching suit this problem?

I do not understand yet Rails' caching system, but I've read in the guides section of a feature called fragment caching. My problem is: my view consist mostly in static elements. It is almost completely static, the only changing is a status message…
Carlos Melo
  • 3,052
  • 3
  • 37
  • 45
1
vote
3 answers

Rails 3: Sweeper not destroying fragments, thinks caching was disabled

I want to expire fragments with a sweeper. The sweeper callbacks are executed, but the calls to expire_fragment do nothing, because (I assume) cache_configured? returns nil. Caching is configured and fragments are being created and used in my…
Jan
  • 3,044
  • 3
  • 20
  • 32
1
vote
1 answer

Active Record query to compute cache key for a view with HABTM associated records?

Student and Parent have a has_and_belongs_to_many relationship, both belong to a School. This query returns the latest timestamp: School.first.students.includes(:parents).maximum("parents.updated_at") Why doesn't this: …
1
vote
1 answer

Fragment caching with Touch

Currently I am using fragment caching with an object key. And I expire the cache using Touch with updates the updated_at column and then the current cache become obsolete. And a new cache is generated the next time. <% cache do product %> The cache…
Gregory
  • 557
  • 6
  • 17
1
vote
0 answers

django template fragment cache not working

I am working on a Django 1.10.1 site and attempting to use fragment caching. However I am not seeing any cache sets or hits in memcached which is the configured backend. If I set a full view cache it caches fine into memcache. Example: {% load cache…
turbotux
  • 422
  • 2
  • 11
1
vote
1 answer

rails 4 cache expiration not working

In my rails app I'm trying to use nested caches, but my cache-key is not expiring when user.profile.full_name is changed. So when user changes his/her name the full_name displayed by _profile_product.html.erb remains the old one. How should I change…
Sean Magyar
  • 2,360
  • 1
  • 25
  • 57
1
vote
1 answer

rails4 double nested models russian-doll-caching

I have the following structure in my rails4 app for the posts. Users can comment on the post and replies can be written on the comments. I'd like to use russian-doll-caching with auto-expiring keys on the page, but I don't know how I should exactly…
1
vote
2 answers

rails4 caching naming conventions

I have a rails 4 app. I have to differentiate the different cache keys somehow but don't know the naming conventions. FIRST EXAMPLE: I have a task model with index, completed_tasks and incoming_tasks actions. A have the same instance name (@tasks)…
Sean Magyar
  • 2,360
  • 1
  • 25
  • 57
1
vote
2 answers

Cannot expire cached fragment by default methods in Ruby on Rails + Devise

I'm using Devise as authenticating solution in Rails and I have a cached fragment :recent_users. I want this fragment to expire when a new user is registered, changed or removed, so I put in my(manually created) users_controller.rb class…
Michael Romanenko
  • 571
  • 1
  • 4
  • 12
1
vote
0 answers

How to use ESI for fragment caching in Varnish, in Ruby on Rails app built on spree?

The basic syntax is not working for me. I would like not to store user specific information in my cache, but want to cache rest of the page. Please provide syntax to do that in Rails app built on Spree.
1
vote
1 answer

MVC, how to organize caching parts of page and how to be with View?

Right now I'm trying to create my own tiny MVC (just for practice and for understanding MVC pattern details). I'd like to cache parts of pages (dropdowns, lists etc.) and I don't know what is the best way to organize it. Let's imagine that I have…
Kirzilla
  • 16,368
  • 26
  • 84
  • 129
1
vote
1 answer

Rails: Trying to understand how to do better fragment caching

In my app I am trying to incorporate better fragment caching. Is it a best practice to do call fragments like this: <% cache("user/#{current_user.id}/info") do %> <%= current_user.email %> information goes here <% end %>
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
1
vote
1 answer

Populate cache in Rails manually

In Rails 3.x I want to precompile my cache manually, and I use fragment caching in the views on model instances and static HTML. Rails lazily populates the cache when the page is requested, which results in a slow loading time on first load. So…
Kenny Meyer
  • 7,849
  • 6
  • 45
  • 66