问题
I have an ASP.Net Web Forms application. The blog post "CacheCow Series - Part 0: Getting started and caching basics" mentions that Output Caching
uses HttpRuntime.Cache
behind the scene -hence not HTTP caching
. The request reaches the server and cached response is sent from the server (when the valid cached output is avaialble on the server). So the entire content is sent across the wire.
Is there any HTTP Caching available for ASP.Net Web Forms (where response content is not sent from the server, if cache is valid; but the client takes it from it's HTTP Cache after getting validity information (only) from the server)?
REFERENCES
- Is page output cache stored in ASP.NET cache object?
- Things Caches Do - Ryan Tomayko - 2ndscale.com/
回答1:
Actually the OutputCache directive is used for both Client as Server side caching. When you set the Location
of that directive to Any
, Client
, Downstream
or ServerAndClient
, proper cache response headers are set such that browsers or proxies won't request the same page again and serve the cached version of your page. But keep in mind that those clients are free to request those pages again.
Location options with their Cache-Control headers after setting directive:
<%@ OutputCache Location="XXX" Duration="60" VaryByParam="none" %>
- Client: private, max-age=60
- Downstream: public, max-age=60
- Any: public
- ServerAndClient: private, max-age=60
- Server: no-cache
- No output directive: private
来源:https://stackoverflow.com/questions/38965684/is-there-any-http-caching-for-asp-net-web-forms