ajax - MVC return PartialView slow first time after edit -
i imagine answer cache related, better understand reason thought i'd @ least ask.
in mvc project i'm doing ajax request controller return html page partial view, inject html page with. reason model view changes depending on what's clicked.
here ajax: (please note code has been modified simplicity)
$.ajax({ type: 'get', url: "../../home/newmembershipalloc/", contenttype: 'application/json', datatype: 'html', success: function (data) { $('#partial_div').html(data); } });
here controller method:
public async task<actionresult> newmembershipalloc() { return partialview("~/views/popup/genericpopup.cshtml", new membership()); }
now, clear, works intended. everytime run code takes maybe 20ms, shown below:
however, if edit html page in way, if remove 1 character , add in. next time perform request take 2 seconds (ish).
so happening within development environment should place html edited. does not happen when refresh page, clear cache or open new browser. questions following:
- what's full reason happening?
- can stop being slow first time? or price pay loading new html?
- would delay ever happen after release? if doesn't use webpage few days example , shuts down machine maybe.
it looks similar question:
https://stackoverflow.com/a/25006809/6862867
in reference above link:
the first time new or edited view requested server parse , compile code. takes small amount of time (but longer you'd expect page load) , required once each time page changes. suspect reason seeing if remove character , add in server not recognise has changed until parse/compile time file has changed since last time loaded.
it seem can precompile project on publish although i'm not clear myself on how done/works.
post release happen first time page loaded. round making request release it.
hope helps :)
wiki
Comments
Post a Comment