OddOneOut / bwp-minify

A WordPress Minification plugin that relies on Minify PHP library and WordPress's enqueueing system to serve minified CSS and JS to your audience
http://betterwp.net/wordpress-plugins/bwp-minify/
49 stars 23 forks source link

Disable db log #60

Open fprezat opened 8 years ago

fprezat commented 8 years ago

Hello,

I wanted to know if it is possible to disable db log for performance issue. update_options is called every time on page load and i want to avoid this.

As i wait for your answer, i patched your plugin as followed, but tell me if there is a better solution to avoid db log.

// in BWP_Enqueued_Detector class
public function commit_logs()
    {
        $this->_logs = array(
            'scripts' => $this->_scripts,
            'styles'  => $this->_styles,
            'groups'  => $this->_groups
        );

        if( defined('WP_DB_MINIFY_LOG') && WP_DB_MINIFY_LOG === TRUE ) {

                        // Log in db
            update_option($this->_log_key, $this->_logs);

        }
    }

Thank you !

kminh commented 8 years ago

Hmm if you don't commit the logs in every request there's a chance of missing enqueued files, which you won't be able to manage their positions.

Maybe there should be a way to cache the logs, similar to how minified contents are currently cached. The cache will be purged when you install/update plugins/themes and when you manually click "Clear cache". What do you think?

fprezat commented 8 years ago

Ok i agree with your idea. So will you implement WP CACHE API ?

In order to understand the mechanism completely, the log generated in every request is used elsewhere in the plugin for enqueuing files, is that right ? So if we disable log, the minification won't occur ?

Thanks.

kminh commented 8 years ago

No we will not use the WP Cache API because WP Object Cache is not persistent by default, and we need to persist the log.

If you disable the log, everything will still work except for the "friendly minify url" feature AND the "manage enqueued files" admin page.

x2764tech commented 8 years ago

Is there any chance you could implement a "learning" mode that can be switched on or off, and only log the requests during the learning mode?

kminh commented 8 years ago

Is there any chance you could implement a "learning" mode that can be switched on or off, and only log the requests during the learning mode?

Let me think about it.