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
@@ -3,6 +3,7 @@ declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Rest;
|
||||
|
||||
use StreamGoals\Core\PageCache;
|
||||
use StreamGoals\Core\GoalTargetPolicy;
|
||||
use StreamGoals\Core\Money;
|
||||
use StreamGoals\Core\Settings;
|
||||
@@ -85,9 +86,8 @@ final class DonateController {
|
||||
$res = rest_ensure_response( self::progress_for( $goal ) );
|
||||
// Short shared cache lets a CDN collapse bursts; the page JS adds a cache-busting parameter after a donation.
|
||||
$res->header( 'Cache-Control', 'public, max-age=10, s-maxage=10' );
|
||||
// LiteSpeed Cache would otherwise hold REST responses for days; it has its own opt-out hook.
|
||||
do_action( 'litespeed_control_set_nocache', 'streamgoals progress' );
|
||||
$res->header( 'X-LiteSpeed-Cache-Control', 'no-cache' );
|
||||
PageCache::skip( 'progress' ); // LiteSpeed would otherwise hold REST responses for days
|
||||
$res->header( PageCache::LITESPEED_HEADER, 'no-cache' );
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ final class DonateController {
|
||||
}
|
||||
|
||||
public static function fee_preview( \WP_REST_Request $req ) {
|
||||
PageCache::skip( 'fee preview' ); // follows the current fee settings and goal status
|
||||
if ( $limited = self::limit( 'preview', 120, 60 ) ) {
|
||||
return $limited;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Rest;
|
||||
|
||||
use StreamGoals\Core\PageCache;
|
||||
use StreamGoals\Core\Settings;
|
||||
use StreamGoals\Overlay\Build;
|
||||
use StreamGoals\Overlay\OverlayService;
|
||||
@@ -54,6 +55,7 @@ final class OverlayController {
|
||||
}
|
||||
|
||||
public static function handle( \WP_REST_Request $req ): \WP_REST_Response|\WP_Error {
|
||||
PageCache::skip( 'overlay data' ); // a cached poll response would freeze the goal bar and alerts
|
||||
if ( ! self::verify_token( (string) $req['token'] ) ) {
|
||||
return new \WP_Error( 'sg_not_found', 'Not found.', array( 'status' => 404 ) );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user