Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update post doesn't seem to refresh cache #117

Open
timheuer opened this issue Oct 31, 2019 · 3 comments
Open

Update post doesn't seem to refresh cache #117

timheuer opened this issue Oct 31, 2019 · 3 comments

Comments

@timheuer
Copy link
Contributor

I may be missing something but looking at the code on FileBlogService.SavePost it does not appear that an update will actually update the _cache -- if the post is new it is added, but if the post is updated, then as long as the _cache object is not rebuild (I can't see where that is invalidated other than app restart) then an updated post is never going to be resident in the cache. Am I missing something?

@madskristensen
Copy link
Owner

Isn't there cache invalidation happening automatically when the .xml file is being touched on disk?

@timheuer
Copy link
Contributor Author

@madskristensen It doesn't appear so. There is HTTP output caching, but even when that is invalidated, the FileBlogService service still gets from the in-memory data cache. Initialize() calls LoadPosts() which creates the _cache object that is used everywhere. In SavePost if it is new then _cache.Add() is called, but only if new...if it isn't, there is no updating of the _cache object or re-trigger of LoadPosts or anything...as far as I can tell.

In practice this also seems to be the case. When I make an edit to a post, it is pretty much never reflected until the app is restarted.

@am11
Copy link
Contributor

am11 commented Nov 21, 2019

BlogController.UpdatePost() gets the same object reference as the one in cache when we update an existing post, so cache reload is not required. For the new posts, this condition gets satisfied:

if (!_cache.Contains(post))
{
_cache.Add(post);
SortCache();
}

When I make an edit to a post, it is pretty much never reflected until the app is restarted.

I have not seen this behavior in my deployment or on the demo website: https://miniblogcore.azurewebsites.net/ (both using FileBlogService). The changes get instantly reflected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants