CondeNast / purgely

A WordPress plugin to manage Fastly caching behavior and purging.
24 stars 9 forks source link

Purges don't seem to work #35

Open jasonevines opened 8 years ago

jasonevines commented 8 years ago

Neither the selective purges that I assume are supposed to happen when posts are added or updated, nor general purges from the command line, appear to be working for me. A Fastly support representative told me, "[T]he API call the plugin is making is incorrect."

schuob commented 8 years ago

From the logs provided it looks like the CLI is making a purge all request to: https://api.fastly.com/service//purge/all

Checked the purgely code base and it shows that it should have been: https://api.fastly.com/service//purge_all

So I'm not sure what's causing the change.

schuob commented 8 years ago

After further testing it looks like if you use wp fastly purge all even though the status says ok - if you curl against the object again the age has not reset to zero this is probably due the API call being incorrect.

Purgely Purge Log : 2016/11/30 (Wed) 03:09:55 https://api.fastly.com/service/<service_id>/purge/all Array
(
    [headers] => Requests_Utility_CaseInsensitiveDictionary Object
        (
            [data:protected] => Array
                (
                    [content-type] => application/json
                    [content-length] => 48
                    [accept-ranges] => bytes
                    [date] => Wed, 30 Nov 2016 03:09:55 GMT
                    [x-varnish] => 2258655757
                    [via] => 1.1 varnish
                )

        )

    [body] => {"status": "ok", "id": "311-1478989259-476098"}

    [response] => Array
        (
            [code] => 200
            [message] => OK
        )

    [cookies] => Array
        (
        )

    [filename] =>
    [http_response] => WP_HTTP_Requests_Response Object
        (
            [response:protected] => Requests_Response Object
                (
                    [body] => {"status": "ok", "id": "311-1478989259-476098"}

                    [raw] => HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 48
Accept-Ranges: bytes
Date: Wed, 30 Nov 2016 03:09:55 GMT
X-Varnish: 2258655757
Via: 1.1 varnish
Connection: close

{"status": "ok", "id": "311-1478989259-476098"}

                    [headers] => Requests_Response_Headers Object
                        (
                            [data:protected] => Array
                                (
                                    [content-type] => Array
                                        (
                                            [0] => application/json
                                        )

                                    [content-length] => Array
                                        (
                                            [0] => 48
                                        )

                                    [accept-ranges] => Array
                                        (
                                            [0] => bytes
                                        )

                                    [date] => Array
                                        (
                                            [0] => Wed, 30 Nov 2016 03:09:55 GMT
                                        )

                                    [x-varnish] => Array
                                        (
                                            [0] => 2258655757
                                        )

                                    [via] => Array
                                        (
                                            [0] => 1.1 varnish
                                        )

                                )

                        )

                    [status_code] => 200
                    [protocol_version] => 1.1
                    [success] => 1
                    [redirects] => 0
                    [url] => https://api.fastly.com/service/<service_id>/purge/all
                    [history] => Array
                        (
                        )

                    [cookies] => Requests_Cookie_Jar Object
                        (
                            [cookies:protected] => Array
                                (
                                )

                        )

                )

            [filename:protected] =>
            [data] =>
            [headers] =>
            [status] =>
        )

)

But if you make a call with wp fastly purge --all --instant the purge request looks like this. After curling the object the Age has reset back to 0.

Purgely Purge Log : 2016/11/30 (Wed) 03:10:26 https://api.fastly.com/service/<service_id>/purge_all Array
(
    [headers] => Requests_Utility_CaseInsensitiveDictionary Object
        (
            [data:protected] => Array
                (
                    [status] => 200 OK
                    [content-type] => application/json
                    [cache-control] => no-cache
                    [fastly-ratelimit-remaining] => 998
                    [fastly-ratelimit-reset] => 1480478400
                    [content-encoding] => gzip
                    [via] => Array
                        (
                            [0] => 1.1 varnish
                            [1] => 1.1 varnish
                        )

                    [content-length] => 41
                    [accept-ranges] => bytes
                    [date] => Wed, 30 Nov 2016 03:10:26 GMT
                    [x-served-by] => app-slwdc9051-SL, cache-sjc3140-SJC
                    [x-cache] => MISS, MISS
                    [x-cache-hits] => 0, 0
                    [vary] => Accept-Encoding
                )

        )

    [body] => {"status":"ok"}
    [response] => Array
        (
            [code] => 200
            [message] => OK
        )

    [cookies] => Array
        (
        )

    [filename] =>
    [http_response] => WP_HTTP_Requests_Response Object
        (
            [response:protected] => Requests_Response Object
                (
                    [body] => {"status":"ok"}
                    [raw] => HTTP/1.1 200 OK
Status: 200 OK
Content-Type: application/json
Cache-Control: no-cache
Fastly-RateLimit-Remaining: 998
Fastly-RateLimit-Reset: 1480478400
Content-Encoding: gzip
Via: 1.1 varnish
Content-Length: 41
Accept-Ranges: bytes
Date: Wed, 30 Nov 2016 03:10:26 GMT
Via: 1.1 varnish
Connection: close
X-Served-By: app-slwdc9051-SL, cache-sjc3140-SJC
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
Vary: Accept-Encoding

"C>X�V*.I,)-V�R��V�����
                    [headers] => Requests_Response_Headers Object
                        (
                            [data:protected] => Array
                                (
                                    [status] => Array
                                        (
                                            [0] => 200 OK
                                        )

                                    [content-type] => Array
                                        (
                                            [0] => application/json
                                        )

                                    [cache-control] => Array
                                        (
                                            [0] => no-cache
                                        )

                                    [fastly-ratelimit-remaining] => Array
                                        (
                                            [0] => 998
                                        )

                                    [fastly-ratelimit-reset] => Array
                                        (
                                            [0] => 1480478400
                                        )

                                    [content-encoding] => Array
                                        (
                                            [0] => gzip
                                        )

                                    [via] => Array
                                        (
                                            [0] => 1.1 varnish
                                            [1] => 1.1 varnish
                                        )

                                    [content-length] => Array
                                        (
                                            [0] => 41
                                        )

                                    [accept-ranges] => Array
                                        (
                                            [0] => bytes
                                        )

                                    [date] => Array
                                        (
                                            [0] => Wed, 30 Nov 2016 03:10:26 GMT
                                        )

                                    [x-served-by] => Array
                                        (
                                            [0] => app-slwdc9051-SL, cache-sjc3140-SJC
                                        )

                                    [x-cache] => Array
                                        (
                                            [0] => MISS, MISS
                                        )

                                    [x-cache-hits] => Array
                                        (
                                            [0] => 0, 0
                                        )

                                    [vary] => Array
                                        (
                                            [0] => Accept-Encoding
                                        )

                                )

                        )

                    [status_code] => 200
                    [protocol_version] => 1.1
                    [success] => 1
                    [redirects] => 0
                    [url] => https://api.fastly.com/service/<service_id>/purge_all
                    [history] => Array
                        (
                        )

                    [cookies] => Requests_Cookie_Jar Object
                        (
                            [cookies:protected] => Array
                                (
                                )

                        )

                )

            [filename:protected] =>
            [data] =>
            [headers] =>
            [status] =>
        )

)