NimChimpsky
NimChimpsky

Reputation: 47290

image and jquery not loading until after refresh in firefox

The first time I visit my site after clearing cache (a jsp page from a spring app) the images and styles are not applied, however when I then do refresh (ctrl-r) everything loads perfectly.

Firefox console output for the image and my (non-cdn) js's:

HTTP/1.1 404 Not Found

The resources it does not find are all the javascript,css, images on my server - the jquery dl's are working.

I can replicate everytime using firefox: clear cache visit site, it fails. Then reload it works. The same is not true of chrome and ie, which seem to be working ok.

To clarify it fails to load javascript and images stored on my server. However the references are obviously correct as it loads perfectly everytime on refresh the same page ... after the relevant jpgs and js are put into local cache ?

Upvotes: 2

Views: 3724

Answers (4)

Francisco Aguilera
Francisco Aguilera

Reputation: 3482

Also, make sure you have type="text/javascript" in your script tags.

Upvotes: -1

Charles
Charles

Reputation: 31

This might help someone.

We had a similar problem: After a complete site re-design we noticed that in Firefox and IE, the first time you show up to the page the CSS styles were not being applied. However firebug showed that they were downloaded, also we had no errors. However upon Refresh the styles were applied and rendered properly.

The Solution: Even though the site re-design was completely new, out of habit our file structure and naming was consistent. Therefore being our NEW style sheet code was completely different but had the exact same file name and folder location as the OLD site.... the browser was trying to use the OLD cached copy of the CSS on first load, however on refresh is forced the use of the newest one.

The Result: We changed the new css styles name, and everything is fixed. This was important to do because we have return visitors that surely were getting the same problem... and most people are not.. hmmmm "clever" enough to hit refresh when the site loads weird, they just go away.

Upvotes: 3

orkutWasNotSoBad
orkutWasNotSoBad

Reputation: 648

You can add versioning with jsp to ensure the browser isn't caching the js and css, like so:

<script type="text/javascript" src="myjs.js?version=20110628a"></script>

That may do the trick.

Upvotes: 0

Liz Rainey
Liz Rainey

Reputation: 36

It may have to do with fuzzy code, the IE can read, because it is not as picky as FF. Make sure you have all you ";" and spacing correct. Also, do your images have self-closing brackets? ( />)

Upvotes: 0

Related Questions