1

I have a web application where a javascript object is loaded via a script tag. The js object is then referenced in another script tag that follows. There is no defer or async attribute on either script. This works without an issue until I get a 304 status on the first script.

Whenever the first script returns a status 304 the application acts as though the object created in the script doesn't exist. As if maybe the scripts are being parsed out of order? The application ends up hanging itself whenever this happens.

The application is a ASP.net MVC application being run on iis7. The web config contains static file handlers for js files.

Also the 304 status seems to be completely random. Sometimes i will get a 200 even when the file hasn't been modified then randomly it will come back as a 304.

This also happens across all browsers.

Has anyone seen this behavior or know why this would happen?

  • This sounds more like a timing issue. `304 Not Modified` means the browser uses the cached result, which can change your timings. Do you have any asynchronous dependencies? – Halcyon Nov 06 '13 at 15:40
  • Important to note: 304 is only returned on subsequent requests after the first necessary request to get the file in the first place. If you're running locally or the browser has not cached the file, then you'll get a 200, even if you've gotten before. It just depends on what the client is doing. – Chris Pratt Nov 06 '13 at 15:42
  • There isn't any asynchronous dependencies. We have even added a setTimeout: $(document).ready(function() { window.setTimeout(onWelcomePageLoad,100); }); onWelcomePageLoad is defined in the js file that is being cached but still get the error that onWelcomPageLoad doesn't exist – J. Nick Baughan Nov 06 '13 at 17:29

0 Answers0