Support » Plugin: WP-FFPC » Non existing page returning http 200 ok

  • Resolved Razza

    (@razza)


    The problem is non-exists pages retuning 200 ok instead of 404 Not Found which is bad for seo
    On Frist load correct http code

    HTTP/1.1 404 Not Found
        Server: nginx
        Date: Wed, 11 Jun 2014 19:02:49 GMT
        Content-Type: text/html; charset=UTF-8
        Transfer-Encoding: chunked
        Connection: keep-alive
        Vary: Accept-Encoding
        Expires: Wed, 11 Jan 1984 05:00:00 GMT
        Cache-Control: no-cache, must-revalidate, max-age=0
        Pragma: no-cache
        Content-Encoding: gzip

    On Second load incorrect http code 200

    HTTP/1.1 200 OK
        Server: nginx
        Date: Wed, 11 Jun 2014 19:03:40 GMT
        Content-Type: text/html
        Transfer-Encoding: chunked
        Connection: keep-alive
        Vary: Accept-Encoding
        X-Cache-Engine: WP-FFPC with memcached via nginx
        Content-Encoding: gzip

    I manage to fix it by change this part in wp-ffpc-acache.php
    Original code

    $prefix_meta = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_meta'] );
    	$wp_ffpc_backend->set ( $prefix_meta, $meta );
    
    	$prefix_data = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_data'] );
    	$wp_ffpc_backend->set ( $prefix_data , $buffer );
    
    	if ( !empty( $meta['status'] ) && $meta['status'] == 404 ) {
    		header("HTTP/1.1 404 Not Found");
    	}
    	else {
    		/* vital for nginx, make no problem at other places */
    header("HTTP/1.1 200 OK");
    	}

    Fixed code

    if ( !empty( $meta['status'] ) && $meta['status'] == 404 ) {
    	  header("HTTP/1.1 404 Not Found");
    	}
    	else {
    		/* vital for nginx, make no problem at other places */
    		$prefix_meta = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_meta'] );
    	    $wp_ffpc_backend->set ( $prefix_meta, $meta );
            $prefix_data = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_data'] );
    	    $wp_ffpc_backend->set ( $prefix_data , $buffer );
    		header("HTTP/1.1 200 OK");}

    After change to code all no existing page returning correct http status HTTP/1.1 404 Not Found

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Non existing page returning http 200 ok’ is closed to new replies.