[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Alex Maghen

1/6/2007 5:18:00 PM

Hi. I'm trying to develop a simple Web Application for Mobile. It's just one
page which will present dynamic data. The page will never be the same twice.
But I try as I may, I don't seem to be able to stop the browser from Caching
the page so that it doesn't re-load it each time.

I've tried things like puting the following in the web.config:
<system.web>
<caching>
<outputCache enableOutputCache="false"
enableFragmentCache="false"
sendCacheControlHeader="false"
omitVaryStar="false">
</outputCache>
</caching>

but that didn't help. What I don't understand is this: When I go to other
sites on my phone (google, etc.), they always seem refreshed and new. How do
I make my application do the same thing?

Alex
5 Answers

stcheng

1/8/2007 2:28:00 AM

0

Hello Alex,

For browser cache, it generally use the http headers cache info to control
the cache behavior. This has nothing to do with the ASP.NET server-side
control setting. You can find some reference describe on the http cache
header:

#5.4.15 Cache Headers
http://www.w3.org/TR/2006/CR-mobile-bp-20060627/#iddiv...

#Caching Tutorial
http://www.mnot.net/c...

And some thread discussing on programmatically disable client cache:

http://forums.asp.net/thread/15...

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.

Alex Maghen

1/8/2007 4:16:00 PM

0

Thanks for these. Another question though - is there a way that I can
implement all of this non-chaching stuff globally for the whole application
so that I don't have to do it on each page?

"Steven Cheng[MSFT]" wrote:

> Hello Alex,
>
> For browser cache, it generally use the http headers cache info to control
> the cache behavior. This has nothing to do with the ASP.NET server-side
> control setting. You can find some reference describe on the http cache
> header:
>
> #5.4.15 Cache Headers
> http://www.w3.org/TR/2006/CR-mobile-bp-20060627/#iddiv...
>
> #Caching Tutorial
> http://www.mnot.net/c...
>
> And some thread discussing on programmatically disable client cache:
>
> http://forums.asp.net/thread/15...
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

stcheng

1/9/2007 3:33:00 AM

0

Thanks for your followup Alex,

Sure, in ASP.NET application, we have the chance to customize the response
of each page(or handler) request globally. That is using the
httpmodule(developing a custom httpmodule). In ASP.NET, each request will
go through a series of httpmodules, you can check the <httpmodules> section
in machine.config or global web.config(in framework folder). Here are some
article that help explain the role & events of httpmodule in ASP.NET
request processing:

http://www.theserverside.net/tt/articles/showarticle.tss?...

http://msdn2.microsoft.com/en-us/library/ms1...

for your scenario, you can create a custom httpmodule and hook one of the
events you can attach in httpmodule. In the event handler, you can check
the current request(check content type or request URL or any other
properties you can get from HttpContext.Current...) and determine whether
this is a request you want to disable the cache of its response. If so, you
can customize the client-side http cache related headers.

Here are some knowledge base articles about creating custom httpmodule:

http://support.microsoft.com/kb/30...

http://support.microsoft.com/kb/30...

Hope these also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.

Alex Maghen

1/9/2007 4:56:00 PM

0

Steven -

Thanks for all this. But a question: Why can't I just put the <meta> tages
and the "Response.Cache.SetCacheability(HttpCacheability.NoCache);" in an
XYZ.master page and then use that on all of my pages? I know that Master
pages aren't part of the Mobile page model and all, but I do seem to be able
to navigate to those pages on my test phones, so can't I just do that?

More importantly, I don't seem to be able to keep the caching from happening
at all, regardless of where I put the code. For some reason, the pages are
being cached anyway on my Blackberry browser. This may not have anything to
do with ASP and may be a matter of the browser. But still, I'm seeing other
pages from other sites where that is obviously not happeneing. Is there a way
that you know of to emulate different mobile browsers on the PC and then look
at their headers and HTTP outputs?

Thanks again.

Alex

"Steven Cheng[MSFT]" wrote:

> Thanks for your followup Alex,
>
> Sure, in ASP.NET application, we have the chance to customize the response
> of each page(or handler) request globally. That is using the
> httpmodule(developing a custom httpmodule). In ASP.NET, each request will
> go through a series of httpmodules, you can check the <httpmodules> section
> in machine.config or global web.config(in framework folder). Here are some
> article that help explain the role & events of httpmodule in ASP.NET
> request processing:
>
> http://www.theserverside.net/tt/articles/showarticle.tss?...
>
> http://msdn2.microsoft.com/en-us/library/ms1...
>
> for your scenario, you can create a custom httpmodule and hook one of the
> events you can attach in httpmodule. In the event handler, you can check
> the current request(check content type or request URL or any other
> properties you can get from HttpContext.Current...) and determine whether
> this is a request you want to disable the cache of its response. If so, you
> can customize the client-side http cache related headers.
>
> Here are some knowledge base articles about creating custom httpmodule:
>
> http://support.microsoft.com/kb/30...
>
> http://support.microsoft.com/kb/30...
>
> Hope these also helps.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

stcheng

1/10/2007 3:25:00 AM

0

Hi Alex,

Thanks for the followup.

Sure, using master page is possible as long as your pages will use a shared
master page.

For the problem that the page still be cached. I think you can first test
the page in a normal PC browser (IE or FF) to see whether it is also
cached. If also cached on PC browser, that means we haven't configure the
page's response cache header correctly. Elsewise, this may be specific to
the device as you said. And for such case, I think you may use some trace
tools to capture the http response message from those pages which are not
cached and your own pages. Compare the response http mesage and headers to
see what's the significant difference.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.