Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22293

Re: Enable java script files caching

Message-ID <20401233.DaGxT2JRNg@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-12-12 21:39 +0100
Subject Re: Enable java script files caching
Newsgroups comp.lang.javascript
References <498464fb-63dd-48a0-b511-01ee2efd621f@googlegroups.com>

Show all headers | View raw


Swetha wrote:

> […]
> Whatevr js files i include in the index.jsp is getting cached, because
> there is no timestamp added to the js URL.

Wrong conclusion.  *No* timestamp being added to the URI would mean that the 
resource is cached on and by the client unless you have explicitly said to 
not cache it and the user agent is obeying your request, or a user 
preference says it should not be cached there.  Also, whether the index.jsp 
resource or rather, the resource generated by it, is cached, does _not_ 
directly depend on the URIs of the resources containing the client-side 
code.

> But the js files included in the subsequent jsps are not getting cached
> due to timestamp added to the js URL.

Whether a resource is cached or not does _not_ depend on its URI.  Instead, 
a potential *already cached* resource is *not used* by the HTTP client if a 
resource with potentially the same content but a *different* URI (e.g., 
different timestamp) is requested from the Web server afterwards.  It 
usually *is* used (and not requested again) if both its content and URI do 
not change.

> My question is how to get rid of timestamp added to js url?

Wrong question.  If you would get rid of the timestamp, the (HTML) content 
*generated* by your index.jsp resource might not change later at all; and 
once cached, unless you or the user said differently, it would be even more 
likely to be used from the client's cache (which you do *not* want).

As a result, the script resource URI should *at most* change when the 
content of the resource changes.

<http://mnot.net/cache-docs>
 
> i am adding the js files in the jsp like follow:
> 
> <script src="js/angular/angular.min.js"></script>
> <script src="js/angular/angular-cookies.min.js"></script>
> 
> i am using struts1. 

Use Struts 2 instead, see <http://struts.apache.org/>.

> PLease help me how to solve this issue

Wrong newsgroup.  For the ECMAScript implementation that you are using 
client-side (e.g., JavaScript), it does not matter how the code that invokes 
it is generated (server-side).  Ask (in proper language and text format) in 
a newsgroup dealing with JavaServer Pages (JSP), which is generating your 
client-side code (at least the HTML code), instead.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Enable java script files caching Swetha <swetha.ganta7@gmail.com> - 2013-12-12 11:09 -0800
  Re: Enable java script files caching Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-12 21:39 +0100

csiph-web