Problem with caching asp.net web pages

I want my asp.net/C# 2008 web pages not to be cached on the client side or on the server side.

How can i do this?

+4
source share
3 answers

For the client side, you want to use No-Cache

http://www.i18nguy.com/markup/metatags.html

Here is a link describing how to configure the response object without caching on the server side:

http://www.extremeexperts.com/Net/FAQ/DisablingBackButton.aspx

Response.Buffer = True Response.ExpiresAbsolute = Now().Subtract(New TimeSpan(1, 0, 0, 0)) Response.Expires = 0 Response.CacheControl = "no-cache" 
+3
source

The page is cached, so the decision not to cache it on the client side is to put this tag:

 <%@ Outputcache Location="None"%> 

before the page tag:

 <%@ page > 

The result is as follows:

 <%@ OutputCache Location="None" %> <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
+1
source

In your question, you do not specify the cache on both the client and the server. For me, this means no caching anywhere.

This will prevent any caching anywhere.

 Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); 

Either put this on the loading of pages that you do not want to cache, or create a base page class.

from http://skysanders.net/subtext/archive/2010/03/23/preventing-caching-of-content-in-asp.net-pages-and-other-httphandlers.aspx

0
source

Source: https://habr.com/ru/post/1306400/


All Articles