Output Cache ASP . Net MVC

Asked

Viewed 144 times

1

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

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

Doubt

If I cache a page, when to use each of the situations? I couldn’t find anywhere to explain the difference in storage between them.

Source: https://docs.microsoft.com/pt-br/aspnet/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs

  • 1

    I think that on this website Voce can find larger references.

  • In this site just explains where is stored each, I would like to know when to use each of them and why.

1 answer

1


Most of the time 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 and he has the files on the machine itself, will only make a HEAD request on the server and if the cache is valid he 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 last request cache.


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 the user Cesar perform the request, will return normally "Hello Cesar", however, when José perform the request after Cesar, 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 need to change the address of your site, so that the user makes the request and does not use the local cache.

Ref: link 1 link 2 link 3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.