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

StackOverflow https://stackoverflow.com/questions/16183420

  •  11-04-2022
  •  | 
  •  

سؤال

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?

هل كانت مفيدة؟

المحلول

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/

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top