added before_intercept and after_intercept functions to allow client side caching