This article is a mirror article of machine translation, please click here to jump to the original article.

View: 24147|Reply: 0

[Source] mvc setting Cache-Control is invalid

[Copy link]
Posted on 11/17/2016 11:18:51 AM | | | |


It turns out that my settings are as follows:



Then, in the network request results, it was found that Cache-Control:private was still this value, and it did not work.

SetLastModified method: Used to set the Last-Modified HTTP header of the page. The Last-Modified HTTP header indicates when the page was last modified, and the cache will rely on it for timing. This method will fail if the cache limit hierarchy is violated. The argument of this method is an instance of the DataTime class.

SetSlidingExpiration method: This method sets cache expiration from absolute to tunable time. Its parameter is a boolean value. When the parameter is true, the Cache-Control HTTP header is updated with each response. This expiration mode is the same as the IIS configuration option that adds the expiration header to all output sets relative to the current time. When the parameter is False, the setting is retained, and any attempt to enable adjustable expiration will statically fail. This method does not map directly to HTTP headers. It is a subsequent module or secondary request to set the origin server caching policy.

SetOmitVaryStar method: A method added ASP.NET 2.0. Used to specify whether the response should include the vary:* header when differentiating by parameter. The method parameter is a boolean value, true to instruct HttpCachePolicy not to use a * value for its VaryByHeaders property; Otherwise it is false.

SetCacheability method: Used to set the Cache-Control HTTP header of the page. This header is used to control how documents are cached on the network. There are two overloading methods in this method, the difference is the parameters. One parameter for an overload method is the HttpCacheability enum values, including NoCache, Private, Public, Server, ServerAndNoCache, and ServerAndPrivate (see MSDN for definitions of these enum values). The other method has two parameters, one is the HttpCacheability enumeration value and the other is a string that represents the cache control extension added to the header. It is important to note that field extensions are only valid when used with Private or NoCache directives. If you combine incompatible instructions and extensions, this method will throw an invalid parameter exception.


Original link: http://www.cnblogs.com/haiyabtx/archive/2012/11/18/2776462.html

Solution:



Finally attached my filter:







Previous:360 browser websites automatically select the speed mode
Next:C# regex takes the value of the A tag href in HTML
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com