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


Groups > comp.lang.javascript > #22292 > unrolled thread

Enable java script files caching

Started bySwetha <swetha.ganta7@gmail.com>
First post2013-12-12 11:09 -0800
Last post2013-12-12 21:39 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#22292 — Enable java script files caching

FromSwetha <swetha.ganta7@gmail.com>
Date2013-12-12 11:09 -0800
SubjectEnable java script files caching
Message-ID<498464fb-63dd-48a0-b511-01ee2efd621f@googlegroups.com>
I have a index.jsp where i am including all the js files and then i am using the jsp:include to include the different jsps depending on struts action. In the subsequent jsps also i am including some js files.

Whatevr js files i include in the index.jsp is getting cached, because there is no timestamp added to the js URL. But the js files included in the subsequent jsps are not getting cached due to timestamp added to the js URL. My question is how to get rid of timestamp added to js url?

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. PLease help me how to solve this issue

[toc] | [next] | [standalone]


#22293

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-12-12 21:39 +0100
Message-ID<20401233.DaGxT2JRNg@PointedEars.de>
In reply to#22292
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web