2

I have a c# MVC webapplication running on a IIS server with bundled javascript.

The application runs smoothly, but once a while for some reason a few scripts won't load. Its always Jquery, Jquery UI and JSSOR slide, a few dozen other files don't have this problem, after i modify the files on the server it works again. So it seems to be a caching issue.

It doesn't occur much, but the problem is that it stops working for a random browser/user, but still works for others. The only thing that works so far is modifying those files.

I'm not sure in which area the problem could come from, so i'm unable to provide any relevant code/config. But if needed i could post it here.

DLE
  • 123
  • 6
  • are you using a minified version of those scripts? – roullie Dec 22 '15 at 09:20
  • I'm sure I had a similar issue with images and set the cache-control header in IIS so that content expired after only a few minutes. The answer from 360Airwalk [in this thread](http://stackoverflow.com/questions/642954/iis7-cache-control) has some information on it. Unfortunately I don't fully understand the implications of doing this so I'm posting a comment. In my case it was a small internal site so I wasn't worried about setting it myself. – Equalsk Dec 22 '15 at 09:39
  • I'm not using a minifed version of those scripts, but the standard MVC Bundling does minify them after bundling, and thanks for the tip Equalsk, i'll look into that, problem is that its quite a large application, so i'll have to check what it does to the performance of the whole application – DLE Dec 22 '15 at 09:46
  • I'm no IIS expert, but I'm pretty sure you can set the HTTP headers on particular portions of the site rather than the whole thing. In my case my images were all in one folder so I set the headers on resources from that folder only, the rest of the site remained unaffected. As long as your Javascript files are in a similar structure then it sounds like the rest of your site should remain unaffected. Good luck! – Equalsk Dec 22 '15 at 10:39
  • Thanks, i've set the specific headers in the scripts folder, application seems to be running fine now. The problem is that the bug can't be reproduced whenever i want it, so hopefully i won't find it anymore – DLE Dec 22 '15 at 10:56

1 Answers1

0

Probably you got the problem with your cache control on the IIS server. please check it. and again, please check if your jquery files are taking time to load and if it is called before they are initialised. and have a look if you're using async and calling the files way before its initialised.

Alok Rajasukumaran
  • 381
  • 1
  • 5
  • 20
  • 1
    If the problem occurs, the scripts won't load at all, not slowly, but not at all. So yeah the scripts are called before they are initialised, but the scripts never will initialize because the files aren't loaded. – DLE Dec 22 '15 at 11:10
  • @DLE Agreed. at times, it may lead to error that script is not there initialised. Hence., please check when its initialised. – Alok Rajasukumaran Dec 22 '15 at 11:46