Support for ETag

In this section, you will learn about how to use ETag in Spring MVC.


 

Ads

Tutorials   
Spring 3.2 MVC insert and retrieve blob from the database The hidden tag The errors tag net.roseindia.dao net.roseindia.service net.roseindia.model net.roseindia.controller Spring 3.2 MVC Hibernate Example Spring 3.2 MVC, Upload File in a specific folder Spring 3.2 MVC Form Handling The textarea tag The options tag The option tag The select tag The radiobuttons tag The radiobutton tag The checkboxes tag mvc:default-servlet-handler Static Resources Configuration View Controllers Configuration View resolvers Spring 3.2 MVC Hello World Example Content Negotiation Configuration Interceptors Configuration using Java or XML Customizing the MVC Java config or XML Namespace MVC Java Config or the MVC XML Namespace Servlet container initialization through code Support for ETag The checkbox tag Autogenerated logical view name through RequestToViewNameTranslator Modification in conventional ModelAndView ControllerClassNameHandlerMapping class for handling convention mapping The password tag The input tag The form tag Form Tag library configuration Customizing the Default Error Page @ExceptionHandler & @ResponseStatus annotation Multipart support for file upload in Spring MVC Themes and Theme resolvers in Spring MVC Locales in Spring MVC ContentNegotiatingViewResolver Redirecting and forwarding to views Chaining of Multiple view resolvers View Resolving through ViewResolver interface Requests Intercepting through a HandlerInterceptor Defining handler methods using @RequestMapping annotation Spring 3.2 Asynchronous Request Processing @RequestMapping annotation for mapping requests @Controller annotation for defining new controller
Ads

Support for ETag

In this section, you will learn about how to use ETag in Spring MVC.

An entity tag or Etag is part of HTTP which provides web cache validation mechanism. This mechanism saves bandwidth because a full response need not send if content is not modified. HTTP/1.1 supported web server utilize Etag , which is an HTTP response header, to find out changes at provided URL.

It can be a good replacement of Last-Modified header. The client can utilize the Etag header, returned by the server with a representation, in subsequent GETs, in an If-None-Match header. If the content at given URL is not changed, the server returns 304:Not Modified.

Servlet filter ShallowEtagHeaderFilter provides ETag support and since it is a plain Servlet Filter , it can be implement with any framework. The ShallowEtagHeaderFilter cache the JSP/ content and creates an MD5 hash over that and returns MD5 hash as an ETag header in the response.

Next time the same resource is requested by a client, it utilizes that MD5 hash as the If-None-Match value. The filter notices this and view is again render by it. After rendering , it compares the two hashes for equality. If they are equal - 304 is returned. This filter ShallowEtagHeaderFilter doesn't save processing because it renders each time to compare hash. It only saves bandwidth since rendered response is not sent back on the bandwidth.

ShallowEtagHeaderFilter can be configure in the web.xml as below :

<filter>
	<filter-name>etagFilter</filter-name>
	<filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class>
</filter>

<filter-mapping>
	<filter-name>etagFilter</filter-name>
	<servlet-name>XYZ</servlet-name>
</filter-mapping>


Advertisements

Share on Google+Share on Google+

Support for ETag

Posted on: January 31, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Support for ETag  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads