Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active July 14, 2021 01:44
Show Gist options
  • Save westonruter/e588bd4ed1778799b19417c838eb5e5e to your computer and use it in GitHub Desktop.
Save westonruter/e588bd4ed1778799b19417c838eb5e5e to your computer and use it in GitHub Desktop.
<?php
/**
* Disable LiteSpeed Cache Comment plugin bootstrap.
*
* @package Disable_LiteSpeed_Cache_Comment
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
* Plugin Name: Disable LiteSpeed Cache Comment
* Plugin URI: https://gist.github.com/westonruter/e588bd4ed1778799b19417c838eb5e5e
* Description: This is needed on sites using the AMP plugin because LiteSpeed Cache by default injects an HTML comment at the end of JSON responses which breaks AMP validation requests.
* Version: 0.2
* Author: Weston Ruter, Google
* Author URI: https://weston.ruter.net/
* License: GNU General Public License v2 (or later)
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
add_filter( 'litespeed_comment', '__return_false' );
if ( ! defined( 'LSCACHE_ESI_SILENCE' ) ) {
define( 'LSCACHE_ESI_SILENCE', true );
}
@westonruter
Copy link
Author

Note that this plugin should no longer be necessary once 1.6 is released, as the plugin will proactively strip such comments as of ampproject/amp-wp#4679.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment