views:

247

answers:

2

I am not sure why I cannot get simple output cache to work and not sure of how to debug a situation like this.

Simply from looking at examples and previous projects I have worked on, I used the following code:

<%@ OutputCache Duration="100" VaryByParam="id" %>

but since that didn't work I tried VaryByParam="*" and VaryByParam="none"

None of these worked.

Are there quick checks to make sure something else is not interfering with OutputCache?

A: 

You are only caching it for 100 seconds, have you tried a longer value? Starting the debugger in Visual Studio could take 100 seconds (or longer!). Also have you tried without the VaryByParam?

James Avery
If starting your debugger is taking 100 seconds... time to buy a new machine! ;)
womp
Don't think Debugger is an issue right...Cause I refreshed a few times (without ever touching code) so if it didn't cache the first time..should cache the next..
TimLeung
+1  A: 

If you're just trying to see if OutputCache is working correctly, you can always add a label to your page that just binds to the current datetime. The first time you load it, it will give you the timestamp of when the label was bound.

The next time the label should update is after the cache has expired and the page is hit again.

<%@ OutputCache duration="120" varybyparam="None" varybycustom="Browser" %>


<asp:Label ID="Testlabel" runat="server" Text=""><%= DateTime.Now %></asp:Label>
womp