clear browser cache automatically?

2,912 views
Skip to first unread message

Magnus

unread,
Mar 29, 2013, 5:24:59 AM3/29/13
to google-we...@googlegroups.com
Hi,

when I deploy a new version of my app on my tomcat server, the clients sometimes need to clear the browser cache.

If the cache is not cleared, an exception occurrs (see below) and the client gets an error message.
The problem is that some clients do not know what to do.

What can I do? Would it be possible to have the browser's cache be cleared automatically somehow?

Thanks
Magnus

-----

Mar 29, 2013 6:38:43 AM org.apache.catalina.core.ApplicationContext log
INFO: SystemServlet: ERROR: The serialization policy file '/bcs/4BF9157EFF4DC4C6EDC037BC1D248013.gwt.rpc' was not found; did you forget to include it in this deployment?
Mar 29, 2013 6:38:43 AM org.apache.catalina.core.ApplicationContext log
INFO: SystemServlet: WARNING: Failed to get the SerializationPolicy '4BF9157EFF4DC4C6EDC037BC1D248013' for module 'http://www.bavaria64.de/bcs/bcs/'; a legacy, 1.3.3 compatible, serialization policy will be used.  You may experience SerializationExceptions as a result.
Mar 29, 2013 6:38:54 AM org.apache.catalina.core.ApplicationContext log
SEVERE: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'bcs.shared.mod.user.UserContext' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = bcs.shared.mod.user.UserContext@1dd3358
        at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:665)
        at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)
        at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
        at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:585)
        at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:605)
        at com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:471)
        at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:563)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
        at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
        at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
        at java.lang.Thread.run(Thread.java:662)

Tomek Kańka

unread,
Mar 29, 2013, 12:38:29 PM3/29/13
to google-we...@googlegroups.com
W dniu piątek, 29 marca 2013 10:24:59 UTC+1 użytkownik Magnus napisał:
Hi,

when I deploy a new version of my app on my tomcat server, the clients sometimes need to clear the browser cache.

If the cache is not cleared, an exception occurrs (see below) and the client gets an error message.
The problem is that some clients do not know what to do.

What can I do? Would it be possible to have the browser's cache be cleared automatically somehow?



Use filter to set headers for "*nocache*" files, which disallows caching.


Magnus

unread,
Apr 1, 2013, 8:56:48 AM4/1/13
to google-we...@googlegroups.com


Am Freitag, 29. März 2013 17:38:29 UTC+1 schrieb Tomek Kańka:
Use filter to set headers for "*nocache*" files, which disallows caching.
 
Hi,

I never used filters before. Could you please explain how to do this or point me to a tutorial?

Thanks
Magnus 

Jens

unread,
Apr 1, 2013, 10:18:33 AM4/1/13
to google-we...@googlegroups.com

JoyaleXandre

unread,
Apr 2, 2013, 1:16:03 PM4/2/13
to google-we...@googlegroups.com
I had the exact same problem this morning and a few other times. If I understand well the Stack Overflow solution, I only have to add a filter in my code and link to it in my web.xml file?
Will it be called automatically or do I need to do something else?

Le lundi 1 avril 2013 10:18:33 UTC-4, Jens a écrit :
http://stackoverflow.com/questions/4274053/how-to-clear-cache-in-gwt

-- J.

Jens

unread,
Apr 2, 2013, 1:37:33 PM4/2/13
to google-we...@googlegroups.com
The filter will be executed when the url-pattern matches. The example uses "/*" as url-pattern which matches all URLs so it will always be executed.

-- J.

Alexandre Joyal

unread,
Apr 2, 2013, 1:42:23 PM4/2/13
to google-we...@googlegroups.com

What is the impact performance wise?

Le 2 avr. 2013 13:38, "Jens" <jens.ne...@gmail.com> a écrit :
The filter will be executed when the url-pattern matches. The example uses "/*" as url-pattern which matches all URLs so it will always be executed.

-- J.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/zToxfg1Rp-o/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jens

unread,
Apr 2, 2013, 2:02:16 PM4/2/13
to google-we...@googlegroups.com

What is the impact performance wise?

Probably the same as if you would add a new if statement to any of your servlets. Just test it in your development environment if you are concerned about it.

We dont do it via a filter as we serve our static content from dedicated web servers. So we configured them to add no-cache headers.

-- J.

ocaner

unread,
Apr 3, 2013, 8:06:07 AM4/3/13
to google-we...@googlegroups.com
Hi Magnus,

an easy solution for this problem, without any need for a filter or changing any http cache headers is to append a query string to the .nocache.js url, e. g.:

<!-- using a version, you'll have to update the HTML file before a planned deployment -->
<script src="m1/m1.nocache.js?version=1.0.1"></script> 
 

<!-- 
   when you have a template engine onboard, like freemarker or jsp, 
   you could use the current time as version either iso or unix timestamp 
   style
-->
<script src="m1/m1.nocache.js?version=${currentTime}"></script> 

<!-- the output would look like this -->
<script src="m1/m1.nocache.js?version=20130329092459"></script> 

Magnus

unread,
Apr 10, 2013, 6:24:21 AM4/10/13
to google-we...@googlegroups.com
Hi,

thanks! Now which solution is better?

Am Mittwoch, 3. April 2013 14:06:07 UTC+2 schrieb ocaner:
<script src="m1/m1.nocache.js?version=1.0.1"></script> 

 
Does it have to be the attribute "version" and does its value have to change on every deployment?

If so, I'd prefer the filter because then I can forget it... .-)

Magnus
Reply all
Reply to author
Forward
0 new messages