Cache Invalidation Sample Code Smart way to Invalidate Cache

Create a new Class 'MyRepository' extending ATG’s GSARepository.

Create an Instance variable to decide whether do we need to invalidate the Cache or Not ? Initialize it with true.

private boolean mInvalidateCaches = true;

Override invalidateCaches() method of ‘GSARepository’, inside this method call the super class method  super.invalidateCaches(),only
if ‘invalidateCaches’ Variable is set to true,and this is 

variable is set from the Versioned Repository component.

Configure Repositories, which are taking part in Versioning
with invalidateCaches=false. This will prevent ATG to invalidate Cache automatically when assets of that repositories are getting deployed.

public void invalidateCaches(){ 

Because we have Overridden invalidateCaches() method in MyRepository class, it will invalidate Cache only if invalidateCaches=true, ATG will not be invalidating the Cache automatically after every Deployment.

Now if you want to see the deployed changes on target, we have to manually invoke invalidateCaches() method using Admin UI, which can be done during off peak hours, so that site performance will not be compromised.

Modify your Versioned Repositories like below.

eg: /atg/commerce/catalog/



Post a Comment

Related Posts Plugin for WordPress, Blogger...