mattheu / MinQueue

WordPress Plugin: Minify and concatenate enqueued scripts and styles
60 stars 18 forks source link

URL to combined CSS / JS changes, creates issue with static page caching #28

Open khromov opened 10 years ago

khromov commented 10 years ago

For some reason, sometimes MinQueue decides to regenerate all the combined files. Since it doesn't clear the page cache in conjunction to this, CSS / JS is now broken, because the cached template still has references to the old MinQueue combiner URL:s. I've tried multiple cache plugins and it's always the same issue.

I guess the root issue is, what could possibly trigger MinQueue to randomly rewrite the files.

donaldG commented 9 years ago

Bump on this. I haven't experienced it, yet, but we use Akamai for a lot of our sites. I'd hate for the cached version, even if just for a few minutes before it refreshes, to be looking for a file that doesn't exist. This plugin seems freaking incredible as I've been testing it locally & would be great to use in our team of folks that may not feel comfortable setting up something like Node/Grunt/Gulp/etc.

donaldG commented 9 years ago

After checking out the Better WP Minify plugin, perhaps a resolution for this would be allowing 'pretty' names for the files, or something similar. I tend to like this plugin a bit more than BWP Minify just because there are less options/distractions. Perhaps something as simple as 'minqueue' w/o the hash. Then maybe each subsequent js/css minqueued file could just be 'minqueue-1', 'minqueue-2', etc.

Maybe something like:

    private function get_group_handle( $group ) {

    if ( empty( $this->group_handles[$group] ) ) {

        $data = array();
        $i = 0;
        foreach( $this->process_queue[$group] as $handle ) {

            $data[$handle] = array( 'version' => $this->class->registered[$handle]->ver );

            $file_path = $this->site_root .  $this->get_asset_path( $handle );
            if ( $this->checks_last_modified && file_exists( $file_path ) )
                $data[$handle]['modified'] = filemtime( $file_path );
        $i++;
        }
            $this->group_handles[$group] = $this->prefix.'-'.$i;

    }

    return $this->group_handles[$group];

}

I'm guessing the purpose of the hash is to give as much info as possible about when the files were created? Maybe there's a way to still include that info without it being dynamically placed into the name. I dunno, just thinking aloud here!