Cache miss on Form POST
-
Hello,
I would like to build a custom form and handle the POST data on a wordpress page. This works okay with add_filter to create dynamic content.
Litespeed shows strange behavior though when calling the page in the form action field – the resulting page will not be served form cache nor will css minimize jump in.
I separated the problem to a difference between GET and POST. When I redirect to a page with GET, the cache will work. If I use POST, the cache is missed.
Example page shows GET and POST button. Please open inspector to follow network traffic and see the difference.
Any help appreciated.
Regards ChrisThe page I need help with: [log in to see the link]
-
Hi,
LiteSpeed Cache only caches “GET” , it won’t cache “POST”
Best regards,
Hello qtwrk,
I would understand, that it won’t be cached for privacy reasons, but minify/combining of css/js files is also not working on the POST request. Why is that?
Regards, ChrisHi,
Please enable debug log , it will say why or what happened.
Best regards,
Hi qtwrk,
here is the part from debug.log
I guess what you mean is “X Cache_control off – not GET method:POST”.
Not caching POST data is ok, but why is optimization skipped?
Thank you for your help.Regards, Chris
——————————————————————————–
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] 💓 ——POST HTTP/1.1 (HTTPS) /dashboard
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] Query String:
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] HTTP_REFERER: https://yoonde.de/dashboard/
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] Accept Encoding: gzip, deflate, br
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] X-LSCACHE: true
05/27/20 06:29:16.500 [109.91.32.181:60812 1 QjW] LSCACHE_VARY_VALUE: +webp
05/27/20 06:29:16.522 [109.91.32.181:60812 1 QjW] [Ctrl] X Cache_control -> stale
05/27/20 06:29:16.535 [109.91.32.181:60812 1 QjW] [Router] get_uid: 0 => LiteSpeed\Router::get_uid()@232 => LiteSpeed\Router::get_role()@251 => LiteSpeed\Conf->in_optm_exc_roles()@653 => LiteSpeed\LSC->after_user_init()@192
05/27/20 06:29:16.535 [109.91.32.181:60812 1 QjW] [Router] get_role:
05/27/20 06:29:16.535 [109.91.32.181:60812 1 QjW] [Media] init
05/27/20 06:29:16.535 [109.91.32.181:60812 1 QjW] [Placeholder] init
05/27/20 06:29:16.535 [109.91.32.181:60812 1 QjW] [CDN] init
05/27/20 06:29:16.535 [109.91.32.181:60812 1 QjW] ⏰ Task init
05/27/20 06:29:16.535 [109.91.32.181:60812 1 QjW] [Router] LSCWP_CTRL bypassed empty
05/27/20 06:29:16.536 [109.91.32.181:60812 1 QjW] [GUI] init
05/27/20 06:29:16.542 [109.91.32.181:60812 1 QjW] [Ctrl] X Cache_control init on
05/27/20 06:29:16.595 [109.91.32.181:60812 1 QjW] [Media] webp replacing: https://yoonde.de/wp-content/uploads/2020/04/yoonde_logo.png => LiteSpeed\Media->replace_webp(https://yoonde.de/wp-content/uploads/2020/04/yoonde_logo.png)@862 => LiteSpeed\Media->webp_srcset(ARRAY)@845 => WP_Hook->apply_filters(ARRAY,ARRAY)@289 =>
/home/yogaalac/yoonde/wp-includes/media.php@206
05/27/20 06:29:16.595 [109.91.32.181:60812 1 QjW] [Media] – replaced to: https://yoonde.de/wp-content/uploads/2020/04/yoonde_logo.png.webp
05/27/20 06:29:16.595 [109.91.32.181:60812 1 QjW] [Media] webp replacing: https://yoonde.de/wp-content/uploads/2020/04/yoonde_logo-300×93.png => LiteSpeed\Media->replace_webp(https://yoonde.de/wp-content/uploads/2020/04/yoonde_logo-300×93.png)@862 => LiteSpeed\Media->webp_srcset(ARRAY)@845 => WP_Hook->apply_filters(ARRAY,ARRAY)@289 =>
/home/yogaalac/yoonde/wp-includes/media.php@206
05/27/20 06:29:16.595 [109.91.32.181:60812 1 QjW] [Media] – replaced to: https://yoonde.de/wp-content/uploads/2020/04/yoonde_logo-300×93.png.webp
05/27/20 06:29:16.677 [109.91.32.181:60812 1 QjW] [Core] Footer hook called
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Core] CHK html bypass: not get method POST
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Ctrl] X Cache_control off – not GET method:POST
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Ctrl] X Cache_control -> no Cache => LiteSpeed\Control::set_nocache()@381 => LiteSpeed\Control::finalize()@640 => LiteSpeed\LSC->send_headers()@466
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Router] get_role:
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Vary] role id: failed, guest
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Router] get_role:
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Router] get_role:
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Vary] no custimzed vary
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] 💰 X-LiteSpeed-Cache-Control: no-cache
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Core] CHK html bypass: not get method POST
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Media] bypass: Not frontend HTML type
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] GUI bypassed by no counter
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Optm] bypass: Not frontend HTML type
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] CDN bypass
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] End response
——————————————————————————–Hi,
From the log
05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Core] CHK html bypass: not get method POST 05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Media] bypass: Not frontend HTML type 05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] GUI bypassed by no counter 05/27/20 06:29:16.680 [109.91.32.181:60812 1 QjW] [Optm] bypass: Not frontend HTML typethe first line
if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) { Debug2::debug2( '[Core] CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ); return; }it just bypasses POST at all , so following
if ( ! $is_html ) { Debug2::debug( '[Core] Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ); return; } Debug2::debug( '[Core] Footer check passed' ); if ( ! defined( 'LITESPEED_IS_HTML' ) ) { define( 'LITESPEED_IS_HTML', true ); }is_html will be false , and
define( 'LITESPEED_IS_HTML', true );won’t happen , so it doesn’t optimize.It seems LSCWP was not designed to check POST output at all.
Maybe you could try
define( 'LITESPEED_IS_HTML', true );on your POST to force LSCWP does optimize.Best regards,
Hello qtwrk,
how cool is that?
That worked!!!Thank you VERY much!
Best regards, Chris
The topic ‘Cache miss on Form POST’ is closed to new replies.