Questions tagged [fragment-caching]
74 questions
23
votes
2 answers
Structuring a Rails app for Russian Doll Caching with a has_many relationship
After studying DHH's and other blog articles about key-based cache expiration and Russian Doll Caching, I am still unsure how to handle one relation type. To be specific, a has_many relationship.
I will share the results of my research on a sample…

mlangenberg
- 1,087
- 11
- 21
18
votes
3 answers
Optimize APC Caching
here is a link to how my APC is running : [removed]
As you can see, it fills up pretty quickly and my Cache Full Count goes over 1000 sometimes
My website uses Wordpress.
I notice that every time I make a new post or edit a post, 2 things happen.…

GreatestSwordsman
- 1,175
- 5
- 20
- 39
14
votes
4 answers
Fragment caching and eager loading: How to get the best of both worlds?
It seems to me that fragment caching and eager loading are -- at least sometimes -- somewhat at odds with each other. Let's say I have a User who has many posts which each has many comments which in turn also can have many comments and so on.
When I…

KaptajnKold
- 10,638
- 10
- 41
- 56
12
votes
2 answers
Russian doll fragment caching with auto expiring keys - performance pros and cons
The question is based on 2 articles:
- Basecamp Next by DHH from 37signals
- Advanced Caching in Rails by Adam Hawkins
I'm a little bit confused about the performance implications of using Russian doll caching, Specifically:
When using auto…

EugeneMi
- 3,475
- 3
- 38
- 57
9
votes
5 answers
ASP.NET MVC output cache with dynamic fragment
How could I cache an entire page except a bit at the top which says something along the lines of "Welcome back, Matt! | Log Out" if the user is logged in and so-on?
I'm using ASP.NET MVC 2.

Matthew H
- 5,831
- 8
- 47
- 82
8
votes
0 answers
Wrong partial is rendered in Rails in some cases, possible fragment caching issue
I have a template that displays a list of events
<%= render partial: 'event', collection: events, cached: true %>
The partial event:
<% cache event do %>
Something
<%= render…

edwardmp
- 6,339
- 5
- 50
- 77
6
votes
2 answers
Rails fragment caching: would 100K+ fragments degrade performance?
I have a site with a large amount of data and I'm doing "Russian doll" caching on all pages like this:
# articles.html.haml
- cache "list of articles", expires_in: 15.minutes do
= render partial: "article", collection: @articles
#…

Hopstream
- 6,391
- 11
- 50
- 81
5
votes
3 answers
Clear partial output caching
I have a page that has controls that are output caches (partial output caching). These are setup like this:
[PartialCaching(86400, null, null, "campaign.whatwhere", true)]
public partial class controls_LatestEnquiriesListCached :…

Niels Bosma
- 11,758
- 29
- 89
- 148
5
votes
1 answer
Pre-build fragment cache (internal approach)
I want to pre-build a partial that takes a few seconds to render. I have seen functions which use proxies to preload the cache via http, but I would like to have an "internal" solution.
This is my function, which is called whenever myobject is…

Railsana
- 1,813
- 2
- 21
- 30
5
votes
2 answers
Fragment Caching with a background worker
I have a page which renders a lot of partials.
I fragment cache them all, which makes it very fast. Horray!
The thing is, that because of the amount of partials, the first run, when writing the cache, takes so long, the request timeout (but the…

Nick Ginanto
- 31,090
- 47
- 134
- 244
4
votes
2 answers
Workaround for content_for use in conjunction with fragment caching
I'm trying to insert content into the head of my page on an per element basis, so I'd like to be able to specify something like this in a partial:
# _partial.html.erb
<%= content_for :style %>
.element {
background-color: red;
}
<% end…

orangemilktea
- 95
- 1
- 6
4
votes
0 answers
touch: true not triggered when object is deleted
I have two models - Post and Comment. I'm using fragment caching to cache each post like so:
- @posts.each do |post|
- cache post do
= render 'posts/post', post: post
post.rb
class Post < ActiveRecord::Base
belongs_to :user, touch: true
…

Arif
- 712
- 11
- 20
4
votes
1 answer
Rails - caching and permission based views
I use CanCan to check user permissions and display or suppress page content conditionally for my users. I want to cache my pages though, and even with fragment caching can't find an elegant solution... for example:
cache do
# much code
if can?
…

Blastula
- 41
- 3
4
votes
2 answers
Fragment Caching with Memcached
Is there any way of using Memcached for fragment caching in Rails?

Codebeef
- 43,508
- 23
- 86
- 119
4
votes
1 answer
rails3 caching: expire fragment with extension
How do I expire a fragment in the cache with a file extension (.json) from a another controller?
I am using Rails 3.2.8.
I have two controllers for the same models: /admin/books_controller and /api/books_controller. The admin controller is used to…

John Naegle
- 8,077
- 3
- 38
- 47