Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Implementing HTTP Caching in New Resources

Implementing HTTP Caching in New Resources

For a new Helix resource, to implement HTTP caching by providing the Cache-Control header , you must create a new Helix prototype that implements the Info interface of the resource.

  1. Create the new resource.
  2. Create a Helix prototype to implement the Info interface.
    For NavigationResource, create an InfoNavigationPrototype that implements the NavigationResource.Info interface as in the following example:
    /**
     * Navigation prototype for Info operation.
     */
    public class InfoNavigationPrototype implements NavigationResource.Info {
    
    	private static final Single<ResourceInfo> INFO_SINGLE = Single.just(ResourceInfo.builder()
    			.withMaxAge(NavigationsResourceConstants.MAX_AGE)
    			.build());
    
    	@Override
    	public Single<ResourceInfo> onInfo() {
    		return INFO_SINGLE;
    	}
    }
    In the prototype, a ResourceInfo is built and the max-age for the resource is returned.