PHP code example of alleyinteractive / wp-page-cache-control

1. Go to this page and download the library: Download alleyinteractive/wp-page-cache-control library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

alleyinteractive / wp-page-cache-control example snippets


wp_page_cache_control()->ttl( 3600 );

wp_page_cache_control()->disable_cache();

wp_page_cache_control()->disable_cache_for_user();

// enabling it again via:
wp_page_cache_control()->enable_cache_for_user();

wp_page_cache_control()->register_group( 'special-user-group' );

// Add the current user to the group (only needs to be done once).
wp_page_cache_control()->set_group_for_user( 'special-user-group', 'segment' );

wp_page_cache_control()->purge( home_url( '/example/' );

wp_page_cache_control()->purge_post( $post_id );

wp_page_cache_control()->purge_term( $term_id );

wp_page_cache_control()->flush();

wp_page_cache_control()->register_group( 'special-user-group' );

wp_page_cache_control()->set_group_for_user( 'special-user-group', 'segment' );

wp_page_cache_control()->is_user_in_group( 'special-user-group' );

wp_page_cache_control()->is_user_in_group( 'special-user-group', 'segment' );

use Alley\WP\WP_Page_Cache_Control\Header;

Header::fake();

namespace Alley\WP\My_Plugin\Tests;

use Alley\WP\WP_Page_Cache_Control\Concerns\Tests_Headers;
use Alley\WP\WP_Page_Cache_Control\Header;
use Mantle\Testkit\Test_Case;

class Example_Test extends Test_Case {
	use Tests_Headers;

	protected function setUp(): void {
		parent::setUp();

		Header::fake();
	}

	public function test_example() {
		// Perform some action that should send a header.

		static::assertHeaderSent( 'X-My-Header', 'optional value' );
		static::assertHeaderNotSent( 'X-My-Other-Header', 'optional value' );

		// static::assertAnyHeadersSent() and static::assertNoHeadersSent()
		// are also available to assert that any headers were sent or not sent.
	}
}