So this project I'm in implemented Bundling (System.Web.Optimization
) to minimize loading times of styles and scripts. My manager is currently looking for ways to shorten loading times even more, because it's still taking too long, and he thinks that one of the reasons is that the Bundling is not working properly. So I've been monitoring the loading times of the scripts on the developer console to see if the cache is not enabled for some reason, and while everything looks fine, the only weird thing I noticed is that the identifier had a different "second token" every time the same page was reloaded. Like so:
http://mypage.com/bundles/Kendo?v=Ly4JCrjDqtOYRbxqbD1I-ubxLYyNieOlYxSxoMmPLYA1&_=1420587597283
http://mypage.com/bundles/Kendo?v=Ly4JCrjDqtOYRbxqbD1I-ubxLYyNieOlYxSxoMmPLYA1&_=1420587659994
http://mypage.com/bundles/Kendo?v=Ly4JCrjDqtOYRbxqbD1I-ubxLYyNieOlYxSxoMmPLYA1&_=1420589994757
The identifier is always the same, but the token at the end is different every time. And I've looked around trying to see if this was addressed somewhere else but didn't find anything. So what I'm asking is, is this normal behavior and nothing worry about?
If it helps, this is the implemented code:
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
BundleTable.EnableOptimizations = true;
bundles.Add(new ScriptBundle("~/bundles/Kendo").Include(
"~/Scripts/kendo/2014.3.1119/kendo.all.min.js",
"~/Scripts/kendo/2014.3.1119/kendo.aspnetmvc.min.js"));
}
}
And
@Scripts.Render("~/bundles/Kendo")
on the meta section of its respective html page.
There are many factors to consider when looking at load times.
Firstly, if you are unsure of what the bundling is doing or you are worried about it being generated on every request, then look in your IIS logs and see if the bundle requests are getting a 304 response (Content not changed) which will tell you that the bundling has been cached by the browser as intended or if indeed it is formulating a new bundle every time.
Ensure you use a browser that supports caching, I know in Chrome you can turn that off to help in debugging which will skew the results.
Also, make sure that you are running with compilation debug="false" in your web.config to take advantage of Razor view caching, rather than it making IO trips to find the views every request.
Checking that you aren't blindly loading every bundle on every view regardless of the view's use. For example, if you have any bundles that deal with validating user input, then ensure these are only loaded when those views are taking user input, save them being loaded on read only views.
I would recommend something like Glimpse to help you diagnose where your load time is being spent. It can help you identify where you have potential wastage.
If you use the Authorize attribute at controller level, ensure you use Anonymous on any actions that don't need to be authorised to ensure you arent spending time authorizing a user that doesnt need to be.
Lastly, check your IIS set up to ensure that you have only the modules loaded that you need and have the compressions facilities turned on to speed up content delivery.