fixed cache purging
fixed X
added cache-type invalidation and checks if cache is enabled