static void PrepareResponse(StaticFiles.StaticFileResponseContext context)
 {
     if (ContentTypes.Contains(context.Context.Response.ContentType))
     {
         context.Context.Response.ContentType += "; charset=utf-8";
     }
 }
Ejemplo n.º 2
0
        internal static void SetCacheHeaders(StaticFileResponseContext ctx)
        {
            // By setting "Cache-Control: no-cache", we're allowing the browser to store
            // a cached copy of the response, but telling it that it must check with the
            // server for modifications (based on Etag) before using that cached copy.
            // Longer term, we should generate URLs based on content hashes (at least
            // for published apps) so that the browser doesn't need to make any requests
            // for unchanged files.
            var headers = ctx.Context.Response.GetTypedHeaders();

            if (headers.CacheControl == null)
            {
                headers.CacheControl = new CacheControlHeaderValue
                {
                    NoCache = true
                };
            }
        }