GWT programming – How to avoid the cache.html files from getting cached in client browser?

December 13, 2013 | Posted in tools, Uncategorized | By

How to prevent ‘nocache.js’ or cache.html from getting cached in Browser when we build Google Web toolkit applications ?
This need arises when you are releasing a newer version of an existing application to existing users. Any user who has visited the GWT application before hand would have cached the previous version files and in all likelihood won’t see the new version changes.
GWT (Google web toolkit ) applications do not work properly in some browsers unless the user refresh the page cache forcefully. If a browser has an older version of this js file or more critical cache.html file cached in the client browser, the application will not be able to properly communicate with server code or render the newer version and most of the time behaves erratically and remains unpredicatable.
Solution for this is to make sure that the older version files specially ‘nocache.js’  & cache.html are not cached by the browser.
 The string in the filename i.e. nocache.js does allow to configure your server to send HTTP header information to the browser to stop it from caching.
To achieve this  In your Java application you have to create a Filter to dispatch the necessary HTTP header information and you can skip the file from getting cached in browser.
Following is the simple Http Filter code:

public class CacheControllerFilter implements Filter{
 
private Logger logger = Logger.getLogger(CacheControllerFilter.class.getSimpleName());
public void destroy() {
}
 
public void init(FilterConfig config) throws ServletException {
}
 
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain){
logger.log(Level.INFO, “[CahcheControllerFilter] in doFilter() method…”);
try {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
String requestURI = httpServletRequest.getRequestURI();
if (requestURI.contains(“.nocache.”)) {
Date currentDate = new Date();
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
httpServletResponse.setDateHeader(“Date”, currentDate.getTime());
// one day old
httpServletResponse.setDateHeader(“Expires”, currentDate.getTime() – 86400000L);
httpServletResponse.setHeader(“Pragma”, “no-cache”);
httpServletResponse.setHeader(“Cache-control”, “no-cache, no-store, must-revalidate”);
}
filterChain.doFilter(request, response);
} catch (Exception ex) {
logger.log(Level.INFO, “[CahcheControllerFilter] Exception in doFilter() method…”,ex);
}
}
 
Headers to be set:
Expires:             Specifies time when the document may change or when its information will become invalid. It shows that it is unlikely the document will change before that time.
Cache-control: Specifies any special treatment a caching system should give to this document. The most common values are no-cache (to indicate this document should not be cached), no-store (to indicate this document should not be cached or even stored by a proxy server, usually due to its sensitive contents), and max-age= seconds (to indicate how long before the document should be considered stale).
 
Pragma:   equivalent of Cache-control, with no-cache as its only possible value.
 
Basically this filter checks whether the http request URI contains the string ”.nocache.”, if it contains then it sets the header to tell the browser to not cache the file, and if it does not then set the Header as it is. Add the extra steps if you want to set header for other files such as cache.html
And  you have to put mapping of this filter in your web.xml file:
<filter>
<filter-name>cacheControlFilter</filter-name>
<filter-class>com.example.server.service.CacheControllerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cacheControlFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

 

email

Read More →

Thank you opensource – enwelib goes opensource

December 9, 2013 | Posted in Uncategorized | By

enwelib – our pathbreaking approach to develop enterprise apps goes opensource

Its been years and tens of projects since we developed and used enwelib. It all started with a need to build a CRM project way back 2008 when we realized GWT was the best client library out there to develop such an app. Just as we set out to work on the CRM app commissioned by a client we realized the endless possibilities of creating a highly reusable and simple library that can make our life easy.

Multitudes of our own past products and project put enwelib and its successive versions to good use.

And time has come for team at Ensarm Solutions to thank the opensource communities for great products such as GWT / Hibernate / MySQL by making enwelib free for all and opensource based.

Its a perfectly usable library for straight forward data driven apps.

As we prepare the necessary documentation to help you figure out the canards of the entire effort, you can lookup the github repo named enwelib to find more information.

We will be writing more about it and its successor AppOps soon.

Follow us on popular social networking sites by clicking on the bar on top to stay updated.

View a snapshot here

Read More →

AppOps shortlisted into IIT Kharagpur Global Entrepreneurship Innovation competition

December 5, 2013 | Posted in Uncategorized | By

This is exciting news. After many years of hard work and many many versions and revisions starting with enwelib in 2008 and renewing the efforts as AppOps in 2011 we are happy to announce the first real public presentation about AppOps. Although we have been using AppOps / enwelib for many of our own and client projects since 2008 / 09 this is the first instance of officially presenting it to a crowd of entrepreneurs and investors alike.

If you recall we presented the earlier version enwelib to a limited set of Google engineers in Google IO 2009 and got highlighted in GWT official gallery then.

If you are wondering what is AppOps at this moment a quick brief is available at AppOps

A lot more details to come soon. Do follow us on any of the social media platforms to stay updated.

Read More →

Web User signup and authorization Series with Java – Part 1 Introduction

November 30, 2012 | Posted in Uncategorized | By

Web development with Java is a breeze, at least for me :) but no doubt its a challenge for a first timer even if he is an accomplished Java developer. The complexity of a web app is possibly easily highlighted when you try and develop a login and authorization module for a web app.

With this series I intend to highlight and document the intricacies and details involved in designing, developing and testing such a module. I am going to use plain breeze Servlets / JSPs / HTML and my favorite GWT ( Google Web toolkit ) etc. As a first step let us look at the various aspects and needs of such a feature in a modern webapp context. A simple looking feature such as this can turn into a nightmare and finding information on the web about all aspects of coding a login was hard to find, at least for me.

Read More →

A team dinner to remember

November 30, 2012 | Posted in Uncategorized | By

The feeling couldn’t be any better. It was an interesting evening full of chaos due to that unbelievable traffic jam that took us about an hour to meet at the restaurant 500 mts away from our office.

Despite the terrible jam and a polluted wait it was nothing but good fun at Shisha cafe all evening to conclude this quarter where we found our focus areas and a promising direction to move towards.

Read More →