Add optional caching to filter.