Please enable JavaScript.
Coggle requires JavaScript to display documents.
1.5 Cache (tools (. (HTML5 specification defined Application Cache API…
1.5 Cache
tools
Donut caching is a server-side technology that caches an entire page other than the pieces of dynamic content—the donut holes.Bad Approach: If you want to cache users by using OutputCache with VaryByParam User ID, then the entire page will be cached every time for each user with a different user name. This is a bad approach because if 5000 users logged into the site, then there will be 5000 pages have been cached.Good Approach: ASP.NET framework called post-cache substitution. Example: Use the HttpResponse.WriteSubstitution() method to enable dynamic content to be injected in a cached page.
Good approach 2: use DonutCaching NuGet package.
Donut Hole caching ChildActionOnlyAttribute (donut holes = the pieces of dynamic content).
Example: add ChildActionOnlyAttribute to some action
and call Html.Action("someAction") from Razor.
DistributionCaching - ability to create data on one application server and share it with the other servers. AppFabric Caching Services is a cache client that communicates with a cluster of cache servers. Your ASP.NET MVC application is an example of a cache client.
Why use System.Runtime.Caching or System.Web.Caching Vs static variables?
Data Caching (System.Runtime.Caching) has automatic expiration control, that can be based on file-changes, SQL Server DB changes, and you can implement your own "changes provider". You can even create dependecies between cache entries. If you don't care about the life-time the name is not caching anymore.
.
HTML5 specification defined Application Cache API (AppCache) to give developers access to local browser cache. To enable the application cache in an application, you must create the application cache manifest, reference the manifest, and transfer the manifest to the client.
-
-
-
-
-
-
Caching is applied
to GET request,
POST, PUT, DELETE
are not affected
-
DonutCache (Layout, no actions)
-
-
tools
OutputCacheAttribute - works well for caching an entire page
VaryBy
VaryByHeader - a semicolon-separated list of HTTP headers that are used to vary the output cache. If you want to vary the cached content by all header values, set the VaryByHeader attribute to an asterisk (*).
VaryByContentEncoding
The Content-Encoding entity header is used to compress the media-type. When present, its value indicates which encodings were applied to the entity-body. It lets the client know, how to decode in order to obtain the media-type referenced by the Content-Type header. Directives: gzip, compress, deflate, identity, br.
VaryByParam - a semicolon-separated list of strings that correspond to query-string values for the GET method, or to parameter values for the POST method. Example 1: Output will be cached based on the City query string value or form post parameter.
Response.Cache.VaryByParams["City"] = true;Example 2: If you want to vary the cached content by multiple parameters, set the VaryByParams property multiple times.
Response.Cache.VaryByParams["City"] = true;
Response.Cache.VaryByParams["Zip"] = true;
VaryByCustom If you specify "browser" for this property, the cache entry will be varied by browser type and major version number. If a custom string is entered, you must override the HttpApplication.GetVaryByCustomString method in your application's Global.asax file.
-
Duration - a value that determines whether to prevent secondary storage of the cached information. Use Duration="0" when you want disable caching.
NoStore - a value that determines whether to prevent secondary storage of the cached information. Informs proxy servers and browser that they should not store a permanent copy of the cached content by setting Cache-Control: no-store within the request header.
-