@Override
 public void onError(final Request request, final Throwable exception) {
   if (exception instanceof StatusCodeException) {
     if (Storage.isSessionStorageSupported()) {
       final Storage storage = Storage.getSessionStorageIfSupported();
       if (storage.getItem(cacheKey()) != null) {
         callback.onResponseReceived(request, getOldResponse(storage));
       }
     } else if (Storage.isLocalStorageSupported()) {
       final Storage storage = Storage.getLocalStorageIfSupported();
       if (storage.getItem(cacheKey()) != null) {
         callback.onResponseReceived(request, getOldResponse(storage));
       }
     }
   } else {
     callback.onError(request, exception);
   }
 }
 @Override
 public void onResponseReceived(final Request request, @Nonnull final Response response) {
   if (response.getStatusCode() == 304 && Storage.isSessionStorageSupported()) {
     final Storage storage = Storage.getSessionStorageIfSupported();
     if (storage.getItem(cacheKey()) != null) {
       callback.onResponseReceived(request, getOldResponse(storage));
       return;
     }
   }
   if (response.getStatusCode() == 304 && Storage.isLocalStorageSupported()) {
     final Storage storage = Storage.getLocalStorageIfSupported();
     if (storage.getItem(cacheKey()) != null) {
       callback.onResponseReceived(request, getOldResponse(storage));
       return;
     }
   }
   if (response.getStatusCode() == 200
       && response.getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE) != null
       && response
           .getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE)
           .equals(CachingScope.USER.name())) {
     serializedResponse = response.getText();
     if (Storage.isLocalStorageSupported()) {
       final Storage storage = Storage.getLocalStorageIfSupported();
       storage.setItem(cacheKey(), serializedResponse);
     }
   } else if (response.getStatusCode() == 200
       && response.getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE) != null
       && response
           .getHeader(DataStoreService.X_VORTEX_CACHE_SCOPE)
           .equals(CachingScope.SESSION.name())) {
     serializedResponse = response.getText();
     if (Storage.isSessionStorageSupported()) {
       final Storage storage = Storage.getSessionStorageIfSupported();
       storage.setItem(cacheKey(), serializedResponse);
     }
   }
   callback.onResponseReceived(request, response);
 }