ASP.Net Invalid Page Caching

一笑奈何 提交于 2019-12-08 08:04:12

问题


Since the database-driven content of my site's home page changes infrequently, I use ASP.Net output caching to keep the content around for 1 hour:

<%@ OutputCache Duration="3600" VaryByParam="none" %>

I have a simple HTML comment at the beginning and end of the .ASCX control that I can use to verify that the output is being cached properly (by using 'view source' from within a browser):

<!--  Cached Area (Created at: 10:08:08 PM)  Begin Cache -->

...

<!--  End Cached Area  -->

The caching itself works great.

However, about once every day or so, ASP.NET captures an EMPTY cached area. As far as I can tell, this is because a robot (or other automated process) is the first thing to stop by the site when the previous cache is invalidated, and due to strange requests from the 'bot, the site creates an empty output... and then caches it.

Of course, this 'blank' section of the site is then seen by humans for the next hour, too.

Is there a way to "query" the output cache to see what's in it? Or (even better), to examine the "proposed" cache to and decide if it's sponge-worthy... err, I mean cache worthy?

I want to instantly dump (or never cache) the output if it doesn't contain the goods.

Note: examining the incoming request for validity is not a good solution, as there could have been a complex series of interactions before the output cache occurs. I need to be able to query the cache itself.

来源:https://stackoverflow.com/questions/4362980/asp-net-invalid-page-caching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!