A little complicated, but here goes. Please keep in mind that my convoluted logic came about because I didn't realize when I created the site that caching could not be accomplished by page.
I set up my site with 4 blogs, siblings under the home page.
The landing page of each blog includes a list of 10 of the latest posts for that particular blog.
The template for the landing page renders those 10 posts with a cachedpartial, based on the blog id:
So I've actually cloned the LandingListPosts partial 4 times so I could hardcode the source of the posts (so I could cache the results)
Now, withing the cached partial, the posts are retrieved like this:
var itemsPerPage = (int)ViewData["ItemsPerPage"];
var posts = PostService.Instance.GetPosts(Umbraco.TypedContent(1242)).Take(itemsPerPage).ToIPublishedContent(true);
@RenderForLanding(posts)
}
The issue I'm having is that I don't always get the correct listing of posts. Sometimes there'll be a few old ones, not the 10 that I'm supposed to retrieve. Sometimes only one.
If I republish and hit that landing page immediately, then I get the correct listing of 10 posts, and it stays that way (clearly because it's cached!)
I know that I've read that a cachedpartial will show the first rendering regardless of any changes in the underlying model. So I'm thinking that somehow the first rendering sometimes pulls an unexpected listing of nodes.
Is it possible that the page is being hit during the publishing process and getting unexpected results because it's in the middle of publishing? Does anyone have any idea what I can do to ALWAYS get the latest 10 posts from a blog and cache the results reliably? I really need to cache because of the site traffic vs server resources. Any help would be appreciated!!
Strange Caching Issue
A little complicated, but here goes. Please keep in mind that my convoluted logic came about because I didn't realize when I created the site that caching could not be accomplished by page.
I set up my site with 4 blogs, siblings under the home page.
The landing page of each blog includes a list of 10 of the latest posts for that particular blog.
The template for the landing page renders those 10 posts with a cachedpartial, based on the blog id:
So I've actually cloned the LandingListPosts partial 4 times so I could hardcode the source of the posts (so I could cache the results)
Now, withing the cached partial, the posts are retrieved like this:
The issue I'm having is that I don't always get the correct listing of posts. Sometimes there'll be a few old ones, not the 10 that I'm supposed to retrieve. Sometimes only one.
If I republish and hit that landing page immediately, then I get the correct listing of 10 posts, and it stays that way (clearly because it's cached!)
I know that I've read that a cachedpartial will show the first rendering regardless of any changes in the underlying model. So I'm thinking that somehow the first rendering sometimes pulls an unexpected listing of nodes.
Is it possible that the page is being hit during the publishing process and getting unexpected results because it's in the middle of publishing? Does anyone have any idea what I can do to ALWAYS get the latest 10 posts from a blog and cache the results reliably? I really need to cache because of the site traffic vs server resources. Any help would be appreciated!!
Thanks!
Steph
Cache is my worst best friend.
I never use cached partial unless it's a footer or navigation.
I know that someone was able to write their own cached partial which was would cache based on the model that was passed to it.
Do you need to cache them? Examine is used under the hood so it should be relatively performant anyway.
Anthony, this was "my bad". I wasn't getting the posts the way I said I was on each partial:
PostService.Instance.GetPosts(Umbraco.TypedContent(1242)).Take(itemsPerPage).ToIPublishedContent(true);
I left some of them with the original code:
Clearly, tag, label, etc was being provided by hitting an author / tag link in the blog -- I hadn't rewritten those links yet.
Thanks!!
Steph
is working on a reply...