My application has been set to cache its resources, but the file ig_WebGrid.xslt is never being cached, and is producing a big overhead. Because is being requested and downloaded several times.
Any idea why this happen?
I recommend using a tool like Fiddler to examine the HTTP response, and see what the cache header is set to for the XSLT file. My guess is that you need to configure your webserver to cache the xslt file type.
First of all, thanks for your fast answer.
I was analizing with fiddler the traffic of my website and that is how i saw that the file ig_WebGrid.xslt was being download several times. Actually is being downloaded 8 times, wich produces an overhead of about 100kb.
My WebServer is configured to cache all the files of the Folder Resources, and this file is in that folder.
This is the header of the request:
GET /WebTest/FinalDrop/Resources/Infragistics/Scripts/ig_WebGrid.xslt HTTP/1.1
Accept: */*
Referer: http://192.168.0.221/WebTest/FinalDrop/Site/Model/BalanceSheet/BalanceSheet.aspx
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8)
Host: 192.168.0.221
Connection: Keep-Alive
Pragma: no-cache
Cookie: ASP.NET_SessionId=n2kjz245grsgxk45qeqmauzn
As you can see it says "Pragma: no-cache", and that is why it is not caching this files. Is there any way to avoid this?
Regards.-
The pragma: no-cache header is added by your webserver, not the WebGrid. You should set an expiration for the content using the cache-control header. For example:
Cache-Control: max-age=3600, must-revalidate
I don't spend a lot of time in IIS, so I'm not sure if there's an easier way to acheive this. Perhaps some of your peers have more experience setting cache control in IIS.
Hello Rumen,
Yes, actually we ended up implementing one of the options you mention.
What we did was create a script with the following content, that is included at the end in every page:
function igtbl_XSLTProcessor(xsltURL){ if(!xsltURL) return null; if(ig_csom.IsIE) { var xslt=ig_createActiveXFromProgIDs(["MSXML2.FreeThreadedDOMDocument","Microsoft.FreeThreadedXMLDOM"]); xslt.async=false; var http = new ActiveXObject("Msxml2.XMLHTTP.3.0"); http.open("GET", xsltURL, false); http.send(); xslt.loadXML(http.responseText); var xslTemplate=new ActiveXObject("MSXML2.XSLTemplate"); xslTemplate.stylesheet=xslt; this.Processor=xslTemplate.createProcessor(); } else { var xmlResp=new DOMParser(); var xmlHttp=new XMLHttpRequest(); xmlHttp.open("GET",xsltURL,false); xmlHttp.send(null); this.Processor=new XSLTProcessor(); this.Processor.importStylesheet(xmlResp.parseFromString(xmlHttp.responseText,"text/xml")); }}igtbl_XSLTProcessor.prototype.addParameter=function(name,value){ if(!this.Processor) return null; if(ig_csom.IsIE) return this.Processor.addParameter(name,value); else return this.Processor.setParameter(null,name,value);};igtbl_XSLTProcessor.prototype.transform=function(){ if(!this.input) return false; if(ig_csom.IsIE) { this.Processor.input=this.input; this.Processor.transform(); this.output=this.Processor.output; } else return this.outputDocument=this.Processor.transformToDocument(this.input); return true;};
The results are just as before, caching works, so the XSLT is only downloaded once.
Thanks for your response!
Hello Dzyann,
Javascript is a prototype language, so even though the original script comes from embedded resources, if you create a function with the same name (from what I see in Tony's fix) and place it after the original declaration, it will override (replace) the original one. So one of the things to try is to place Tony's javascript fix at the very bottom of your page and see if it works for you.
The second option you have is to switch from using internal assembly resources to external ones, with the fix applied. This should not be that difficult, setting JavaScriptFileName and Path should be enough.
The third option is to contact Developer Support directly, but even if this is entered in our queue, it will get some time before it gets fixed / tested and released in a HotFix.
Hi Tony,
First of all, let me tell you, your previous fix worked like a charm, so thanks again.However, now we are having the same issue in another application that doesn't have the javascript files deployed along with the site, but rather lets the ultrawebgrid use its embedded resources, so we can't apply your fix by changing the JS directly.
Any ideas on how to get around this?
Glad I could help!
Amazing! Thank you very much!
I changed the code you indicated me, and now the cache is working fine (I verified this with fiddler).
That problem was driving me crazy! I should go church and pray for you! You saved my life!