remove old javascript file

220 views
Skip to first unread message

bhomass

unread,
Jun 17, 2010, 8:40:55 PM6/17/10
to Google Web Toolkit
is there any way to programmatically get user browser to delete all
its cached javascript files in order to push down new ones?

Sripathi Krishnan

unread,
Jun 18, 2010, 1:02:06 AM6/18/10
to google-we...@googlegroups.com
No, you can't do that. But if you set appropriate cache headers, there is never a need to delete old files.

--Sri


On 18 June 2010 06:10, bhomass <bho...@gmail.com> wrote:
is there any way to programmatically get user browser to delete all
its cached javascript files in order to push down new ones?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


bhomass

unread,
Jun 26, 2010, 6:14:45 PM6/26/10
to Google Web Toolkit
do you mean to set a limited cache lifetime or to not cache at all?

I do normally want the javascript files to be cached for performance
purposes.

On Jun 17, 10:02 pm, Sripathi Krishnan <sripathi.krish...@gmail.com>
wrote:
> No, you can't do that. But if you set appropriate cache headers, there is
> never a need to delete old files.
>
> --Sri
>
> On 18 June 2010 06:10, bhomass <bhom...@gmail.com> wrote:
>
> > is there any way to programmatically get user browser to delete all
> > its cached javascript files in order to push down new ones?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

Sripathi Krishnan

unread,
Jun 26, 2010, 6:30:11 PM6/26/10
to google-we...@googlegroups.com
Its obviously a great idea to cache, and GWT makes it really easy to do that.

There are in general three buckets of cache settings that you should know about - 
  1. Cache Forever -  Any file that has the extension .cache.xxx falls in this category. It is safe to set a far-in-the-future expires header. If this file ever changes, GWT guarantees it will generate a completely different file name.
  2. Never Cache - The bootstrap <module-name>.nocache.js, and your host html/jsp page falls under this category. The browser should never cache these files, and you should specify the right http headers to ensure this.
  3. Cache for sometime - Every other file falls under this category. In general, you should use ClientBundle so that files don't end in this category. GWT generated js/html files will never come under this category. You can choose to set an expires header ranging from a few hours to a few days, depending on how frequently you change your code. 
This thread on stackoverflow has the necessary http header details. This is GWTs official documentation that explains the meaning of all these weird ile extensions.

--Sri


To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

André Severo Meira

unread,
Jun 26, 2010, 9:44:34 PM6/26/10
to google-we...@googlegroups.com
Nice!


 
2010/6/26 bhomass <bho...@gmail.com>
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

bhomass

unread,
Jul 7, 2010, 10:09:54 PM7/7/10
to Google Web Toolkit
I don't understand something. according to you, none of the generated
js would fall under "cache for sometimes". That means all the js files
except nocache.js would be cached forever. and GWT takes care that new
file names will be generated when this type filed change. By this
logic, there could never be any stale js problem. yet, I see in
repeated cases, where someone's browser displays old app design, and
clearing browser cache brings up the latest. How can that be?

On Jun 26, 6:44 pm, André Severo Meira <andrex1...@gmail.com> wrote:
> Nice!
>
> 2010/6/26 bhomass <bhom...@gmail.com>
>
> > do you mean to set a limited cache lifetime or to not cache at all?
>
> > I do normally want the javascript files to be cached for performance
> > purposes.
>
> > On Jun 17, 10:02 pm, Sripathi Krishnan <sripathi.krish...@gmail.com>
> > wrote:
> > > No, you can't do that. But if you set appropriate cache headers, there is
> > > never a need to delete old files.
>
> > > --Sri
>
> > > On 18 June 2010 06:10, bhomass <bhom...@gmail.com> wrote:
>
> > > > is there any way to programmatically get user browser to delete all
> > > > its cached javascript files in order to push down new ones?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Google Web Toolkit" group.
> > > > To post to this group, send email to
> > google-we...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > google-web-tool...@googlegroups.com<google-web-toolkit%2Bunsu...@googlegroups.com>
> > <google-web-toolkit%2Bunsu...@googlegroups.com<google-web-toolkit%252Buns...@googlegroups.com>

Sripathi Krishnan

unread,
Jul 8, 2010, 8:37:06 AM7/8/10
to google-we...@googlegroups.com
I see in repeated cases, where someone's browser displays old app design, and clearing browser cache brings up the latest. How can that be?

A few things can go wrong - 
  1. Browser is caching <module>.nocache.js. If this happens, the browser will also download the stale *.cache.html files. And, you if you have made changes to RPC services, this will manifest itself as IncompatibleRemoteServiceException.
  2. Browser is caching css/html/images, so even if your code is new, the look-and-feel will be old.
As I mentioned earlier, the problem is best mitigated by getting rid of the third "Cache for Sometime" bucket by making aggressive use of ClientBundle.

--Sri


To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

bhomass

unread,
Jul 20, 2010, 5:13:33 PM7/20/10
to Google Web Toolkit
I found a number of conflicting comments concerning this. And, even if
they are in sync, I have questions on how to set cache control.

1. you stated - *Never Cache* - The bootstrap <module-
name>.nocache.js, and your host html/jsp page falls under this
category. The browser should never cache. but the first reference
above says
(2) Changing occasionally (public / equal for all users)
Examples: index.html, mymodule.nocache.js

which sounds like you should cache for short time.

I am unsure how I would set the cache control for the
module.nocache.js. The js file is cotained in the app.hmtl. do I set
<meta http-equiv="Cache-Control" content="no-store"> in the header of
that page?

should I use no-store or no-cache?

2. you stated - *Cache for sometime* - Every other file falls under
this category. In
general, you should use ClientBundle so that files don't end in
this
category. GWT generated js/html files will never come under this
category.
You can choose to set an expires header ranging from a few hours to
a few
days, depending on how frequently you change your code.

I can be sure whether you are saying to use client bundle so that
nothing ever get cached for sometime. if so, why do you also specify
"set an expires header ranging from a few hours to a few days"?





Stefan Bachert

unread,
Jul 21, 2010, 9:48:31 AM7/21/10
to Google Web Toolkit
Hi,

the bootstrap code should never be cached.

Assume you are deploying a new version.
The bootstrap code refers the browser/locale specific JS using an own
strong name.
If you cache the bootstrap file, it may happen that old bootstrap code
refers to old strong named file
which are no more existing.

Stefan Bachert
http::/gwtworld.de

due to recent cases, I am sorry, I won't do free personal support.
inquiries for professional GWT support are welcome.

bhomass

unread,
Jul 21, 2010, 5:46:56 PM7/21/10
to Google Web Toolkit
I understand that. assuming you are calling the module.nocache.js the
"bootstrap" code.

my last question is HOW to make it not cacheable. I know about using
meta tag to mark a page uncacheable, but how do you make one .js
uncacheable?

Stefan Bachert

unread,
Jul 22, 2010, 3:23:55 AM7/22/10
to Google Web Toolkit
Hi,

caching is controlled by the container. THere is no general way to
configure it.
On Jetty you have to extend web.xml
On Apache you have to configure some .conf or .htaccess
On GAE there is an appconfig


Stefan Bachert
http::/gwtworld.de

Inquiries for professional GWT support are welcome.
I am sorry, I won't do free personal support.



Reply all
Reply to author
Forward
0 new messages