• Post Reply Bookmark Topic Watch Topic
  • New Topic

css and .js files being cached?

 
Jamie Williams
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JSF application with some simple javascript functions in a .js file referenced in every one of my pages. It seems that changes to these files aren't being picked up by some computers (actually, everyone else's computer at work) and I can't figure out why.

In my browser I make some changes to some data which are validated by the javascript functions when I submit them, and get taken to the next page. This works only on my computer, everyone else goes through the submission progress and gets returned to the same page (default behaviour for if no changes to the data have been made).

Another problem is with my stylesheet. Clearing the browser cache completely doesn't help. I made a small change to my stylesheet for the <a> styles and now they don't show the right thing at all.

Here is my stylesheet code:


Is there anything wrong with my code? Does Tomcat cache these sort of files for some reason? This is a real pain and I would really appreciate any help anyone can give me!
 
Jamie Williams
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I fixed the problem with



But I am concerned about one thing - does this cause the jsp pages to recompile every time they are requested?
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jamie Williams:
...

But I am concerned about one thing - does this cause the jsp pages to recompile every time they are requested?


It shouldn't.

I was trying to figure out why I don't have thise problem, and realized it's because I almost always have to bounce Tomcat when I change stuff anyway.

I don't think Tomcat's actually caching the CSS, but from the looks of it, your browser is. Normally, you'd want to cache CSS and JavaScript for performance reasons - just not while you're debugging the stuff.

I think your problem on the server side is that when a webapp is updated in situ there's a polling interval (adjustable, I believe) for changes in the content and until that interval expires, Tomcat will continue to serve up the stale content instead of your updates. Combine that with browser caching and I can see where you'd become very annoyed.
 
Jamie Williams
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've fixed it with the above code, but I'm sure I will take it out later once most of the development is finished.

When I was using Firefox I could solve the CSS problem easily by typing in the full address of the stylesheet in the browse and refreshing it if neccessary. But now, my boss (not a programmer) made us switch from Linux to Windows and banned us from using anything other than IE and IE for some reason won't let you type in the address of a .js or .css file. It's annoying!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!