CSP nonce




Wordpress LScache Plugin: CSP nonce

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi, I try to include scripts-styles nonces thru template_redirect hook, works well but theres 2 scripts remaining out of scope cause they are generated by LSCache plugin. Those are with data-no-optimize property in just after head and before /body tags, so theyve no nonce set. Is there a way to add them a nonce and add those nonces to CSP extra header ? I tried with litespeed_buffer_after but it does not work Thanks a lot > I tried with litespeed_buffer_after but it does not work Could you please explain a bit what or how exactly did you do ? Here is my code: add_action( template_redirect, function () ob_start( function ( $output ) $nonces = [] $output = preg_replace_callback( ##, function ( $matches ) use ( &$nonces ) $nonce = wp_create_nonce( $matches[0] ) $nonces[] = $nonce return str_replace(



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference