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>
22 lines
720 B
PHP
22 lines
720 B
PHP
<?php
|
|
declare( strict_types=1 );
|
|
|
|
namespace StreamGoals\Core;
|
|
|
|
/**
|
|
* Keeps live responses out of page caches. LiteSpeed Cache stores REST responses (and pages sending
|
|
* nocache_headers()) for days unless told otherwise, which freezes overlays that poll for changes.
|
|
*/
|
|
final class PageCache {
|
|
|
|
public const LITESPEED_HEADER = 'X-LiteSpeed-Cache-Control';
|
|
|
|
/** Call before any output, early enough that error responses are covered too. */
|
|
public static function skip( string $reason ): void {
|
|
do_action( 'litespeed_control_set_nocache', 'streamgoals ' . $reason );
|
|
if ( ! headers_sent() ) {
|
|
header( self::LITESPEED_HEADER . ': no-cache' ); // also covers LiteSpeed server caching without the plugin
|
|
}
|
|
}
|
|
}
|