Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Browser's caching take into account Parameters in the URL? (ASPX page)

I want a particular aspx page cached in the browser. I have valid reasons for having it as an ASPX page and I need the caching on the browser.

Now, on the server cache, I can vary the caching by parameter. Does the browser too take into account parameters while caching page responses?

E.g. Will the following two responses be saves as two different cache items on the browser? http://mypage.com/page.aspx?Param=1 and http://mypage.com/page.aspx?Param=2

like image 654
Moiz Tankiwala Avatar asked Aug 29 '12 14:08

Moiz Tankiwala


People also ask

How does browser caching work?

The basic idea behind it is the following: The browser requests some content from the web server. If the content is not in the browser cache then it is retrieved directly from the web server. If the content was previously cached, the browser bypasses the server and loads the content directly from its cache.

How can we prevent browser from caching an ASPX page?

Use the SetNoStore() method as follows, in the ASPX page: <%@ Page Language=”C#” %> <% Response. Cache. SetNoStore(); Response.

How does browser caching affect web design?

Caching is an incredibly useful feature that works by temporarily storing data closer to the user. By distributing shared page elements such as Javascript, CSS, and images this way, a website can attain a host of benefits – all of which positively impact the underlying business.

What is caching of URL?

Caching is the temporary storage of web documents such as HTML pages and images. Basically, your web browser stores copies of web pages you've visited recently to reduce its bandwidth usage, server load, and lag.


2 Answers

Yes, browser will treat those urls as 2 different resources so it will cache them separately (in case cache headers indicates to do so).

You could easily test it using Fiddler.

like image 76
Claudio Redi Avatar answered Sep 20 '22 23:09

Claudio Redi


Edit 2: How to instruct browsers to ignore GET parameters when caching a resource describes a similar problem, and if you want to cache both of those pages as the same page, it may be difficult. If you want them to be different, you should be set with default behavior, but make sure that your

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="CACHE">

tag is set to explicitly tell the browser to do it.

Original answer:

You can choose if you want it to. For example, if you want those to cache differently, set an output cache with varyByParam="param":

<%@ OutputCache Duration="60" VaryByParam="Param" %>

if you do not use the vary by param option, both of those pages will cache the same. If you want to vary by multiple parameters, separate them with semicolons. If you want to vary by all params, us the * wildcard:

<%@ OutputCache Duration="60" VaryByParam="*" %>

More info on output caching: http://msdn.microsoft.com/en-us/library/y96218s9.aspx

Edit: Just re-read your question. This will cause caching on the server side, not browser.

like image 45
MaxPRafferty Avatar answered Sep 18 '22 23:09

MaxPRafferty