OutputCacheLocation.ServerAndClient does not work!

-1

I'm using OutPutCache with the OutputCacheLocation.ServerAndClient parameter in an action that always returns images to me; However, the browser always downloads the images (it does not save them in cache), if I use OutputCacheLocation.Client it works perfectly but I need the cache to be on the server side and the client.

I do not understand what happens. This is my code:

[HttpGet]
[OutputCache(Duration = 43200,Location = OutputCacheLocation.ServerAndClient, VaryByParam = "*")]
public ActionResult GetImagenProducto(int id, int width = 800, int height = 800, int calidad = 90)
{
    
asked by Davis 08.08.2018 в 20:09
source

1 answer

0

I found the solution on the site in English. This is a translation of the AlexC response:

You can use OutputCacheLocation.Any that specifies that

  

The output cache can be found in the client's browser (where the request originated), in the proxy server (or any other server) participating in the request, or in the server where the request was processed. This value corresponds to the enumeration value HttpCacheability.Public .

You may also want to specify Cache-control to public in the HTTP header for those requests.

Edition

It seems that depending on the .Net version of the server, you may need to include Response.Cache.SetOmitVaryStar(true); in the action of the controller to remove the Vary headers as you suggest.

Details of the reason why in the .Net 4 release notes .

    
answered by 23.08.2018 в 23:30