I am using the standard outputcache tag in my MVC app which works great but I need to force it to be dumped at certain times. How do I achieve this? The page that gets cached is built from a very simple route {Controller}/{PageName} - so most pages are something like this: /Pages/About-Us
Here is the output cache tag that is at the top of my .aspx view page just to be clear:
<@ OutputCache Duration="100" VaryByParam="None" %>
So in another action on the same controller where content is updated I need to dump this cache, or even all of it - it's a very small app so not a big deal deal to dump all cached items.
Be careful about using "None" vs. "".
I used Fiddler to verify this behavior.
This seems to have an impact on whether or not the browser goes back to the server to check for latest version (causing a 304). At least in Chrome it does. You want to use Varies=""
if you know for sure you aren't going to want to update the file before it has expired.
I'd recommend using Varies=""
as I did in this post. For my javascript file I dont want the browser going back and making another Http request until it has expired. 304 is unnecessary.