Output ASP .NET MVC Cache

1

I am studying about the output cache in Asp .NET MVC to improve the performance of my application. From what I've seen it can be stored in various places like:

· Any
· Client
· Downstream
· Server
· None
· ServerAndClient

Doubt

If I cache a page, when to use each of these situations? I have not found any place to explain the difference in storage between them.

Source: link

    
asked by anonymous 13.11.2018 / 10:22

1 answer

1

Most often the Any cache will meet the expectation, as it performs the Local / Proxy / Server cache.

If you have an ecommerce and it has a category page, where the user will select which category he wants to access.

This type of information can be "cached" anywhere, when the user tries to access it and has the files in the machine itself, will only make a HEAD request on the server and if the cache is valid it responds with the data that is on the local machine, if a user who has never accessed your system tries to access it, it will use the cache of the last request.

You should not cache sensitive information on the server / proxy, see the following situation:

  [OutputCache(Duration = 3600, VaryByParam = "none")]
    public string GetName()
    {
        return "Olá " + User.Identity.Name;
    }

If user Cesar performs the request, he will normally return "Hello Cesar", but when José completes the request after Cesar, he will return the information "Hello Cesar".

Related to the local cache, if you need a complete update on the page, and make it impossible to access the old page, you would need to change the address of your site, so that the user can perform the request and not use the local cache.

Ref:

> link 2 link 3

    

14.11.2018 / 18:01