Keep overlays and live responses out of LiteSpeed Cache
LiteSpeed Cache held overlay poll responses for 7 days, so OBS kept getting 304s and neither the goal bar nor alerts updated after a donation. The overlay data, overlay pages and fee preview now opt out, as the progress route did. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0180aacd72
commit
96bae1cbf9
6 files changed
+61
-3
No files matched your search
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/** Live responses must opt out of page caching, or OBS overlays freeze behind LiteSpeed Cache. */
|
||||
final class PageCacheOptOutTest extends TestCase {
|
||||
|
||||
public function test_every_live_response_opts_out_of_page_caching(): void {
|
||||
$root = dirname( __DIR__, 2 ) . '/includes/';
|
||||
$expected = array(
|
||||
'Rest/OverlayController.php' => "PageCache::skip( 'overlay data' )",
|
||||
'Overlay/Router.php' => "PageCache::skip( 'overlay page' )",
|
||||
'Rest/DonateController.php' => "PageCache::skip( 'fee preview' )",
|
||||
);
|
||||
foreach ( $expected as $file => $call ) {
|
||||
$this->assertStringContainsString( $call, (string) file_get_contents( $root . $file ), $file );
|
||||
}
|
||||
$helper = (string) file_get_contents( $root . 'Core/PageCache.php' );
|
||||
$this->assertStringContainsString( 'litespeed_control_set_nocache', $helper );
|
||||
}
|
||||
|
||||
public function test_overlay_opts_out_before_the_token_check_so_404s_are_not_cached(): void {
|
||||
$src = (string) file_get_contents( dirname( __DIR__, 2 ) . '/includes/Rest/OverlayController.php' );
|
||||
$this->assertLessThan( strpos( $src, 'self::verify_token( (string)' ), strpos( $src, 'PageCache::skip(' ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user