在ASPX中缓存 [英] Cache in ASPX

查看:88
本文介绍了在ASPX中缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在ASPX中使用缓存,但是设置过期不能执行.请照顾:

我插入了一行:

Hi all,
I use cache in ASPX but set expire can not excute. Pls look after:

I inserted line:

<%@ OutputCache Location="Client" Duration="60" VaryByParam="CID" %>



在代码隐藏中,在页面加载事件中:



In code behide, in page load event:

if (Cache["Test"] == null)
            {
                Cache["Test"] = 123;
            }
            else
                Label1.Text = Cache["Test"].ToString();



1分钟后,我刷新浏览器,但Label1.Text ="123";

请帮我!



After 1 min i refresh browser but Label1.Text = "123";

Pls help me!

推荐答案

看看这一部分: VaryByParam ="CID"
知道这意味着什么吗?在这里查看Vary-by-param缓存的详细信息: @ OutputCache [ ^ ]
基于参数缓存页面的版本 [
更多阅读:
在.NET中进行缓存 [缓存概述 [
Have a look at this part: VaryByParam="CID"
Any idea what that means? Have a look at the details of Vary-by-param caching here: @ OutputCache[^]
Caching Versions of a Page, Based on Parameters[^]

You get back the value as 123 as caching is varied by ''CID'' querystring value.

More reads:
Caching in .NET[^]
Overview of caching[^]


Sandeep是正确的,您在代码中忘记了这一点.您必须看一下写得很好的这篇文章.

在ASP.NET中浏览缓存 [
Sandeep is right, you forgot the thing in the code. You must take a look at this article which is well written.

Exploring Caching in ASP.NET[^]


这篇关于在ASPX中缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆