Ipstenu / varnish-http-purge

Proxy Cache Purge
Apache License 2.0
46 stars 47 forks source link

Enhance `wp varnish debug` #50

Closed danielbachhuber closed 6 years ago

danielbachhuber commented 6 years ago

Three specific enhancements:

  1. Headers are fetched twice, with a 1 second delay in-between checks. Doing so ensures our Age header verification is always accurate:
| Age Headers    | Good    | Your site is returning proper "Age" headers.                |

Fixes #44

  1. If no plugin / theme conflicts are found, the report output indicates accordingly:
| Theme Success  | Good    | No themes were found on the Varnish conflicts list.         |
| Plugin Success | Good    | No active plugins were found on the Varnish conflicts list. |
+----------------+---------+-------------------------------------------------------------+

Fixes #46

  1. Introduces --include-headers flag to include headers in the debug report:
$ wp varnish debug --include-headers
Headers:
 - date: Mon, 18 Jun 2018 20:30:02 GMT
 - content-type: text/html; charset=UTF-8
 - set-cookie: __cfduid=dbb4f9cf29134b6384d543c6e171373841529353802; expires=Tue, 18-Jun-19 20:30:02 GMT; path=/; domain=.breakwpdh.com; HttpOnly
 - link: <https://varnish.breakwpdh.com/wp-json/>; rel="https://api.w.org/", <https://varnish.breakwpdh.com/>; rel=shortlink
 - x-cacheable: YES:Forced
 - x-varnish: 345999835 345999828
 - age: 11
 - expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
 - server: cloudflare
 - cf-ray: 42d082f0cd448d05-PDX
 - content-encoding: gzip
+----------------+---------+--------------------------------------------------------------+
| name           | status  | message                                                      |
+----------------+---------+--------------------------------------------------------------+
| Cache Service  | Awesome | Your Varnish caching service appears to be running properly. |

Fixes #45


Test this branch in a remote environment with:

wp plugin install --force https://github.com/Ipstenu/varnish-http-purge/archive/varnish-debug-enhance.zip
danielbachhuber commented 6 years ago

You repeat the sleep check in status.php and wp-cli.php. Wouldn't it make more sense to put in the remote_get() function (in debug.php) so we don't have to repeat it and the headers?

Potentially, although that changes the behavior of remote_get() which I'm not sure is a good thing.

Ipstenu commented 6 years ago

It wouldn't be harmful as far as I can see. I was messing with it this way in 4.6 (enter the dev mode):

https://github.com/Ipstenu/varnish-http-purge/blob/REL_4.6/debug.php#L111

Wouldn't that be the same thing?

danielbachhuber commented 6 years ago

It wouldn't be harmful as far as I can see. I was messing with it this way in 4.6 (enter the dev mode):

Ah, I didn't realize remote_get() already made two requests. I've updated in 3ebe6f5de1c833c11ecd9ecb3b58f94917803fec