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.
Thanks again for your answer.
I have been researching about what you indicated me. I have set the Cache-Control as you indicated me and in other diferent ways.
No matter what i do always happen the same, I see in the response of the server that the Cache-Control i set is being set in it as i indicated. But the request always has Pragma: No-Cache. And then the files are always received several times.
Is possible by any matters that i am configuring something wrong on the grids that forces the "Pragma: No - Cache" and that is why i get several times the same file?
Or maybe i am just missunderstanding the way this function.
I see that this same file is sent several times, once for each Infragistic control that i have on the page. And this just doesnt seem right, since is always the same file. Maybe this is the way is supposted to work?
Sorry for this so many questions, and thanks again for your answers.
The grid adds a script tag to the HTML output which has the URL to the xslt file. Other than that, the grid has no control over how or where that file comes from. What browser are you using to view the files? Is it possible that you have changed your browser settings to remove all temporary internet files (the browser cache)? Also, if you click on the refresh button for a page, all cached content will be downloaded again. Is it possible that your method for testing is involving forcing the browser to re-download the content?
I am using IE. And no i dont have the IE set to delete all the content.
What confuses me big deal, is that i have set the cache and all. And the only file that is not being cached is the ig_WebGrid.xslt, the rest of the files are being cached, images and .js and other.
I really dont know what is going on with this. Our pages use Infragistics heavily, and therefore this specific file produces an important overhead, if it would be requested just once each time the page is requested... But is being requested 8 times, in the page I am working on right now, because there are 8 Infragistics controls on the page. And this is each time the page is being requested.
I will keep researching on this, and i hope i can find where i am mistaken.
Thanks for your answers!
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!