Reputation: 2050
What is HTTP headers in asp.net. How do they work? I want to use them to cache in output cache for varybyheader.
Upvotes: 0
Views: 2996
Reputation: 1547
Output caching in asp.net can be done by means of declarative syntax meaning in the markup page you can declare them alone with page directives .Syntax given below.
<%@ OutputCache Duration="#ofseconds"
Location="Any | Client | Downstream | Server | None |
ServerAndClient "
Shared="True | False"
VaryByControl="controlname"
VaryByCustom="browser | customstring"
VaryByHeader="headers"
VaryByParam="parametername"
VaryByContentEncoding="encodings"
CacheProfile="cache profile name | ''"
NoStore="true | false"
SqlDependency="database/table name pair | CommandNotification"
ProviderName="Provider Name"
%>
Suppose if you want to cache the page based on the language you can use the HTTP headers called "Accept Language". So if it will cache page content for languages specific like French,Chinese,Japanese.
<%@ OutputCache Duration="10800" VaryByParam="State;City" VaryByHeader="Accept-Language" %>
Like this you can cache the page based on HTTP headers .
Accept Content-Types that are acceptable Accept: text/plain Accept-Charset Character sets that are acceptable Accept-Charset: utf-8 Accept-Encoding Acceptable encodings Accept-Encoding: Accept-Language Acceptable languages for response Accept-Language: en-US
Links referred: http://msdn.microsoft.com/en-us/library/ms972362.aspx http://msdn.microsoft.com/en-us/library/hdxfb6cy.aspx http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
Upvotes: 1
Reputation: 30862
Each piece of data is transmitted over the internet via a protocol called HTTP - you can't do anything about this as its the way the internet has been designed.
Each piece of this data is seperated up into chunks - each of which needs a header to provide an explanation to its contents, this is a HTTP Header.
Using these headers you can request the browser to perform certain actions on your behalf (it is under no obligation to follow) such as:
I believe the second is the one you require.
ASP.NET is wonderful however - you don't need to fiddle about with HTTP Headers. The framework will do that for you.
Upvotes: 4