Mike Flynn
Mike Flynn

Reputation: 24325

Outputcache override with query string showing non cache version in asp.net mvc

Id like to show a page non cached, but still take advantage of outputcache. Say a admin would like to see the page updated in real time by adding a query string nocache=1 to the url, then the outputcache wouldnt show the cached version, but if the query string is left off it would. Can I do this?

Upvotes: 1

Views: 1257

Answers (2)

Tommy
Tommy

Reputation: 39807

The best alternative would probably be to implement a custom cache provider which, when given a certain set of parameters, does not cache the page. Here is one such example:

http://www.haneycodes.net/custom-output-caching-with-mvc3-and-net-4-0-done-right/

Upvotes: 1

Shawn Steward
Shawn Steward

Reputation: 6825

If you create some miscellaneous parameter and configure the output caching to varyByParam, you should be able to call it with different values each time, it should bypass the cache... However I'm not sure this would be the best way to do that. You may want to just create a separate action for the admin to access that is secured.

Upvotes: 0

Related Questions