Title: Filter before cache
Last modified: July 18, 2018

---

# Filter before cache

 *  Resolved [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * (@nextendweb)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/filter-before-cache/)
 * Hi [@keycdn](https://wordpress.org/support/users/keycdn/),
    it would be great
   if you could add a filter into your `set_cache` method:
 *     ```
           public static function set_cache($data) {
   
               // check if empty
               if ( empty($data) ) {
                   return '';
               }
   
               $data = apply_filters('cache_enabled_before_minify', $data);
   
               // store as asset
               call_user_func(
                   array(
                       self::$disk,
                       'store_asset'
                   ),
                   self::_minify_cache($data)
               );
   
               return $data;
           }
       ```
   
 * It would allow plugin developers to modify the response before it is cached. 
   Autoptimize contains the same filter with the name `autoptimize_filter_html_before_minify`.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [sebastiankro](https://wordpress.org/support/users/sebastiankro/)
 * (@sebastiankro)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/filter-before-cache/#post-10504596)
 * Thank you for the feedback. We’ll look into this for a future release.
 * Meanwhile, you can disable Cache Enablers minify feature and use Autoptimize 
   additionally. Both plugins work very well together and you should then be able
   to use Autoptimizes filter?
 *  Thread Starter [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * (@nextendweb)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/filter-before-cache/#post-10504728)
 * Thanks [@sebastiankro](https://wordpress.org/support/users/sebastiankro/)! I’m
   the developer of Smart Slider 3 plugin and not a real user. Our plugin starts
   an output buffer too, but ours is on init action while yours is on template_redirect.
   Our changes should happen before your cache, so we should start our output buffer
   later. What works the best if we have a filter which we can subscribe and we 
   can adjust the output when needed.
 * I refered Autoptimize as we use their filter too.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Filter before cache’ is closed to new replies.

 * ![](https://ps.w.org/cache-enabler/assets/icon.svg?rev=2442383)
 * [Cache Enabler](https://wordpress.org/plugins/cache-enabler/)
 * [Support Threads](https://wordpress.org/support/plugin/cache-enabler/)
 * [Active Topics](https://wordpress.org/support/plugin/cache-enabler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cache-enabler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cache-enabler/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Nextendweb](https://wordpress.org/support/users/nextendweb/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/filter-before-cache/#post-10504728)
 * Status: resolved