Cache middleware