The cache has a global scope and is maintained for the duration of your web application. This is not for http request.
You can verify this with simple code.
<asp:TextBox ID="txtData" runat="server" Width="200px"></asp:TextBox> <br /> <asp:Button ID="btnPutToCache" runat="server" Text="Put to Cache" onclick="btnPutToCache_Click" /> <br /> <asp:Button ID="btnGetFromCache" runat="server" text="Get from Cache" onclick="btnGetFromCache_Click" /> <br /> <asp:Label id="lblGetFromCache" runat="server"></asp:Label>
And codebehind:
protected void btnPutToCache_Click(object sender, EventArgs e) { Cache["data"] = txtData.Text; } protected void btnGetFromCache_Click(object sender, EventArgs e) { lblGetFromCache.Text = Cache["data"].ToString(); }
Put all of the above code on one page. Expand your website. Remove the page from the instance of your browser window, place the test text in the text box and click the "Put in cache" button.
Open a new browser window and click on the page. Click the Get from Cache button and see the results.
source share