• Resolved vandreev

    (@vandreev)


    Hey Raul,
    first of all thanks for your efforts in making this plugin! Now, I do have a slight issue with the ‘Dev Options’ – the preload header isn’t working. You seem to have changed the cache directory from ‘/fvm/out’ to cachedirurl var (/cache/fvm/{digits}/out) and as a result its no longer working. When you get a chance, can you please fix this. I’ve been playing around a bit and have done the following changes, hope it helps:

    
    Index: wp-content/plugins/fast-velocity-minify/fvm.php
    <+>UTF-8
    ===================================================================
    --- wp-content/plugins/fast-velocity-minify/fvm.php	(date 1562194291000)
    +++ wp-content/plugins/fast-velocity-minify/fvm.php	(date 1562276274128)
    @@ -2845,7 +2845,7 @@
     # collect all fvm JS files and save them to an headers file
     add_filter('script_loader_tag', 'fastvelocity_collect_js_preload_headers', PHP_INT_MAX, 3 );
     function fastvelocity_collect_js_preload_headers($html, $handle, $src){
    -	global $collect_preload_js, $fvm_enabled_css_preload, $fvm_enabled_js_preload;
    +	global $cachedirurl, $collect_preload_js, $fvm_enabled_js_preload;
     	
     	# return if disabled
     	if ($fvm_enabled_js_preload != true) { 
    @@ -2853,16 +2853,32 @@
     	}
     	
     	# collect
    -	if (stripos($src, '/fvm/out/') !== false) { 
    +	if (stripos($src, $cachedirurl) !== false) {
     		$collect_preload_js[] = $src;
     	}
     	return $html;
     }
    +
    +add_filter('style_loader_tag', 'fastvelocity_collect_css_preload_headers', PHP_INT_MAX, 3 );
    +function fastvelocity_collect_css_preload_headers($html, $handle, $src){
    +    global $cachedirurl, $collect_preload_css, $fvm_enabled_css_preload;
    +
    +    # return if disabled
    +    if ($fvm_enabled_css_preload != true) {
    +        return $html;
    +    }
    +
    +    # collect
    +    if (stripos($src, $cachedirurl) !== false) {
    +        $collect_preload_css[] = $src;
    +    }
    +    return $html;
    +}
     
     # generate preload headers file
     add_action('wp_footer', 'fastvelocity_generate_preload_headers', PHP_INT_MAX); 
     function fastvelocity_generate_preload_headers(){
    -	global $collect_preload_css, $collect_preload_js, $fvm_enabled_css_preload, $fvm_enabled_js_preload;
    +	global $cachedirurl, $collect_preload_css, $collect_preload_js, $fvm_enabled_css_preload, $fvm_enabled_js_preload;
     	
     	# return if disabled
     	if ($fvm_enabled_css_preload != true && $fvm_enabled_js_preload != true) { 
    @@ -2889,7 +2905,7 @@
     		foreach($collect_preload_css as $u) {
     			
     			# filter out footer footer files, because they are not in the critical path
    -			if(stripos($u, '/fvm/out/footer-') !== false) { continue; }
    +			if(stripos($u, $cachedirurl . '/footer-') !== false) { continue; }
     			
     			# add headers
     			$headers[] = "Link: <$u>; rel=preload; as=style";
    @@ -2901,7 +2917,7 @@
     		foreach($collect_preload_js as $u) {
     			
     			# filter out footer footer files, because they are not in the critical path
    -			if(stripos($u, '/fvm/out/footer-') !== false) { continue; }
    +			if(stripos($u, $cachedirurl . '/footer-') !== false) { continue; }
     			
     			# add headers
     			$headers[] = "Link: <$u>; rel=preload; as=script";
    
    

    Kind Regards,
    Ves.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Raul P.

    (@alignak)

    Sorry, but before I dive into this, did you try to purge the cache and resave the settings again?

    • This reply was modified 4 years, 9 months ago by Raul P..
    Thread Starter vandreev

    (@vandreev)

    Yes, you have hard-coded paths whilst your cache-dir is dynamic.

    Plugin Author Raul P.

    (@alignak)

    You are right, although I think this is probably not working since 2.6.0 when I first implemented numeric cache directories (that’s the timestamp).
    Thank you very much, fixed it on 2.6.8

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Dev Options – Link header broken’ is closed to new replies.