madskristensen / WebEssentials.AspNetCore.OutputCaching

Other
52 stars 17 forks source link

SetSlidingExpiration keeps stale page in cache too long #4

Open markheath opened 6 years ago

markheath commented 6 years ago

I am using this in a blog inspired by MiniBlog.Core, and ran into a problem with the way pages are added to the cache.

Because it uses SetSlidingExpiration when adding to the MemoryCache, if there is semi-regular traffic to a page it can remain in the cache for a very long time. This is a problem if you create a sheduled blog post as the home page needs to be purged from the cache but because no files on disk have changed nothing will trigger this. Could it be changed to an absolute expiry time or at least have the option to choose?

I also noticed that when entries are cached they include the host so depending on the domain name you use to visit a page you can see different results. But OutputCachingService.NormalizeRoute seems to assume the host is not included in the key for the cache.