WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP JS] Is the gzip'd file cached? (2 posts)

  1. geoken
    Member
    Posted 5 years ago #

    I was wondering if the cached js is the just minified version or if the gzip'd version is cached as well (to reduce gzip related cpu load)?

    http://wordpress.org/extend/plugins/wp-js/

  2. ty
    Member
    Posted 5 years ago #

    I just found this plugin. Haven't tried it yet but it looks good and will hopefully save me much time. It seems from lines 33–47 of the wp-js-compress.php file in the version 2.0.6 code, that the gzip'd version is indeed cached.

    if(extension_loaded('zlib') && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')){
    		ob_start('ob_gzhandler');
    		header('Content-Encoding: gzip');
    	} else {
    		ob_start();
    	}
    
    	header("Content-type: text/javascript; charset: UTF-8");
    	header("Cache-Control: max-age=".$wp_js['cache']);
    	header("Expires: " .gmdate("D, d M Y H:i:s", time() + $wp_js['cache']) . " GMT");
    
    	if (!wp_js_is_expired($wp_js['file']) && @file_exists('cache/'.wp_js_filename($wp_js['file']))) {
    			include('cache/'.wp_js_filename($wp_js['file']));
    	 } else {
    		ob_start("wp_js_clean");

    peace~

Topic Closed

This topic has been closed to new replies.

About this Topic