locked
Calling action having output cached by jquery ajax RRS feed

  • Question

  • User-454825017 posted

    when an action has output cache attribute then if i call that action by jquery repeatedly then should i get result or not

    suppose my action has output cache attribute and action return html to jquery ajax as json. so when action will be called by jquery first time then it will be cached and when the same action will be called again by jquery then should get any data at client side or not?

    thanks

    Monday, October 19, 2020 7:42 AM

Answers

  • User475983607 posted

    1) Suppose i am caching action at client side then what will happen if i call that action by jquery ? action will not be invoke? if invoke then what result will be return ?

    Is there some reason why you are unable to test this yourself?  

    2) NoStore=true : The NoStore property is used to inform proxy servers and browser that they should not store a permanent copy of the cached content.

    when we cache then we mention cache duration then what will be advantage of NoStore ?

    please guide me for my 2 questions. thanks

    A proxy is an intermediate device sitting between the client and the server that makes requests on the behalf of the client.  NoStore controls whether content is cached on the proxy. 

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs#where-content-is-cached

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 19, 2020 2:11 PM
  • User-474980206 posted

    If it’s cached, then the result will be the cached result. The browser handles caching, jQuery does not know if the result was cached or not. The no cache option, jquery add a random query string parameter to the request url, so it can not be found in the cache.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 19, 2020 2:21 PM

All replies

  • User475983607 posted

    TDP

    when an action has output cache attribute then if i call that action by jquery repeatedly then should i get result or not

    suppose my action has output cache attribute and action return html to jquery ajax as json. so when action will be called by jquery first time then it will be cached and when the same action will be called again by jquery then should get any data at client side or not?

    The cache location depends on your configuration.   See the official documentation; https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs

    Monday, October 19, 2020 12:50 PM
  • User-454825017 posted

    1) Suppose i am caching action at client side then what will happen if i call that action by jquery ? action will not be invoke? if invoke then what result will be return ?

    public class UserController : Controller
        {
            [OutputCache(Duration=3600, VaryByParam="none", Location=OutputCacheLocation.Client, NoStore=true)]
            public string GetName()
            {
                return "Hi " + User.Identity.Name;
            }
        }

    2) NoStore=true : The NoStore property is used to inform proxy servers and browser that they should not store a permanent copy of the cached content.

    when we cache then we mention cache duration then what will be advantage of NoStore ?

    i assume if i use NoStore then data will not be cached then what will be use of using outputcache attribute?

    tell me please what is meaning of this outputcache [OutputCache(Duration=3600, VaryByParam="none", Location=OutputCacheLocation.Client, NoStore=true)]

    please guide me for my 2 questions. thanks

    Monday, October 19, 2020 1:53 PM
  • User475983607 posted

    1) Suppose i am caching action at client side then what will happen if i call that action by jquery ? action will not be invoke? if invoke then what result will be return ?

    Is there some reason why you are unable to test this yourself?  

    2) NoStore=true : The NoStore property is used to inform proxy servers and browser that they should not store a permanent copy of the cached content.

    when we cache then we mention cache duration then what will be advantage of NoStore ?

    please guide me for my 2 questions. thanks

    A proxy is an intermediate device sitting between the client and the server that makes requests on the behalf of the client.  NoStore controls whether content is cached on the proxy. 

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs#where-content-is-cached

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 19, 2020 2:11 PM
  • User-474980206 posted

    If it’s cached, then the result will be the cached result. The browser handles caching, jQuery does not know if the result was cached or not. The no cache option, jquery add a random query string parameter to the request url, so it can not be found in the cache.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 19, 2020 2:21 PM