Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I Want to Cache bulk of js files.  RSS feed

 
Senthil Kumar
Greenhorn
Posts: 21
Chrome Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I am including a lot of js files in JSP. It tooks too much of time to load. I want to cache the JS files.

For Example:

I have a JSP namely -> MyFirstDemo.jsp
In MyFirstDemo.jsp i have 10 js files included.
I am accessing this MyFirstDemo.jsp many times. it took long time to load because of js files. i want to reduce the time taken for the JSP to load all those js files.

Is there any way to do this.

Thanks in Advance.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JS files should be cached by the browser. You can use a tool like the LiveHttpHeaders Firefox extension to ascertain whether or not those files are transferred again after the first page load. If they are, make sure the browser's cache isn't turned off, that proper last-modification dates are sent for the JS files, and that HTTP pipelining isn't turned off in the browser.

You could also combine those files into fewer than 10 files, but I doubt that that will make a big difference if caching and HTTP pipelining work properly.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Senthil,
When you say "include", do you mean referencing internal files or rendering their contents in the page. If the former, I agree with Ulf that they should be cached. If not, it is best to use the format:
<script language="JavaScript1.1" src="[your file].js"></script>
This allows the browser to cache the file between requests from the same client.
 
Senthil Kumar
Greenhorn
Posts: 21
Chrome Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Guys..

I have included my JS Files like this.

<script language="JavaScript1.1" src="[your file].js"></script>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!