When the ig.Loader executes to load script required by a page, it seems to make several trips to the server, even if a component has already been loaded, returning code 304. However, even though there is no need to actually download the code, it seems to consume significant time making multiple trips to the server. For a given browser session, can we issue the ig.loader function once to load all components that will be needed, then omit the function in subsequent pages? Will those pages first attempt to use whatever has been cached by the initial call to ig.loader to load scripts/css? What is the best way to use ig.Loader to limit trips to the server to download script, even if the component scripts have already been loaded?
Hello,
We have a topic on How to use the igLoader.
Also make sure you are not referencing the components explicitly. And you can also send a sample, so we can review what you're experiencing.
Keep in mind that for best performance you can download the minified files with the widgets you want from here.
Thank you for your response. I reviewed the topic How to use the igLoader again (did that when initially configuring for it), but it didn't provide the needed answers. What I would like is to avoid the 304 responses entirely. The following describes what I would like to do.
On the initial page for my app I would like to include the following to get all resource required for the igGrid (assuming a simple grid that isn't using any features).
$.ig.loader({ scriptPath: 'http://localhost/igniteui/js/', cssPath: 'http://localhost/igniteui/css/', resources: 'igGrid' }});
On subsequent pages I want to use the igGrid, but I want to use cached resources. If I issue the above code on this second page I just get the 304 response. However, since I know that I obtained the resources when the first page was executed, there should be no need to attempt to get resources at all. So I just want to execute the following so the page knows where the Infragistics script/css is located. However, when I execute any code on this page that uses the igGrid I get the error "Uncaught TypeError: $(...).igGrid is not a function". It doesn't appear that cached resources are being used. Since I know that the first page of my app has already obtained and cached the needed igGrid resources, my goal is to avoid requesting the igGrid resource at all on subsequent pages of my app, thus avoiding a trip to the server that does nothing but return the 304 response but doesn't download any additional resources.
$.ig.loader({ scriptPath: 'http://localhost/igniteui/js/', cssPath: 'http://localhost/igniteui/css/' }});
I think I didn't understand something here.
You want to avoid 304 responses entirely, but the 304 response means that this is a cached resource(Not modified).
If you are refreshing a subsequent page completely, not just part of it you need to load the resources you will be using, no matter if you were using them into your initial page.
But here comes the caching, which is done by the browser. And if detects you are loading a resource which is cached it returns 304 status code.
Loading the resource once can be done if you load them into your initial page and then use AJAX(for example) for the subsequent pages.
Yes, I wish to avoid the 304 responses since we already know the code has been cached by a previous page load. But what I'm understanding from you is that each page must request the code from the server, regardless (unless we're using AJAX to load the page or portions of it) of whether or not we know it's already cached. It would be nice if the igLoader detected that the resources were already cached and did not send a request to the server for the resouces again, only to get the 304 response.
I wish that the answer to my question were different, but I understand that this is just how it works.