Skip to content

Commit

Permalink
Better explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Dec 17, 2023
1 parent 0841598 commit eb3511c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/LinkDotNet.Blog.Web/Features/Home/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
// The hot path is that users land on the initial page which is the first page.
// So we want to cache that page for a while to reduce the load on the database
// and to speed up the page load.
// That will lead to stale blog posts for 5 minutes for the first page,
// but I am fine with that (as publishing isn't super critical).
// That will lead to stale blog posts for 5 minutes (worst case) for the first page,
// but I am fine with that (as publishing isn't super critical and not done multiple times per hour).
// It might be tackled in the future (for example invalidate option via Admin UI).
if (Page == 1)
{
currentPage = await MemoryCache.GetOrCreateAsync(firstPageCacheKey, async entry =>
{
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5);
return await GetAllForPageAsync(Page.Value);
return await GetAllForPageAsync(1);
});
return;
}
Expand Down

0 comments on commit eb3511c

Please sign in to comment.