Bugfix: flush cache if not using external cache or if filter is modified

Currently it will ONLY flush caches if using an external cache and if the filter is not modified, the inverse of what we want.