Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Post does not purge homepage #27

Closed
schuob opened this issue Jun 8, 2016 · 5 comments
Closed

New Post does not purge homepage #27

schuob opened this issue Jun 8, 2016 · 5 comments

Comments

@schuob
Copy link

schuob commented Jun 8, 2016

When adding a new post Purgely does not purge the homepage.

  1. create a new post and preview to see the id that will be used as the surrogate-key for the post
  2. publish, Purgely will send a purge request
    https://api.fastly.com/service/<service-id>/purge/post-52
  3. The homepage will not be updated with the new post because the current cache of the homepage does not have surrogate-key post-52.
@tollmanz
Copy link
Collaborator

Hi @schuob!

There are a lot of things that can impact this. For each page request, Purgely examines the global $wp_query object for post IDs related to the current request. If the post ID is in the current main query, the key corresponding to the post is added to the surrogate key list.

I have a few questions for you:

  1. Are you seeing any surrogate keys added to the homepage?
    1. If yes, do they correspond to the posts on the page?
  2. Are you doing anything special on your homepage outside of displaying the latest posts? Frequently, homepages utilize custom queries to pull in collections of posts outside the latest posts. If you are doing this, those post IDs will not be included in the surrogate keys. The plugin has no awareness of custom functionality so it cannot add those for you. If this is the case for you, there is a method for adding additional keys and I can help you with that.

@schuob
Copy link
Author

schuob commented Jun 15, 2016

@tollmanz thanks for checking in

Are you seeing any surrogate keys added to the homepage? If yes, do they correspond to the posts on the page?

So after I make a new post here is the surrogate-key for the homepage

curl -svo /dev/null http://stevenchuob.asuscomm.com/
*   Trying 98.210.217.69...
* Connected to stevenchuob.asuscomm.com (98.210.217.69) port 80 (#0)
> GET / HTTP/1.1
> Host: stevenchuob.asuscomm.com
> User-Agent: curl/7.48.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Wed, 15 Jun 2016 18:40:59 GMT
< Server: Apache/2.4.10 (Raspbian)
< Surrogate-Key: post-60 post-55 post-52 post-49 post-44 post-40 post-37 post-34 post-31 post-9 template-home
< Surrogate-Control: max-age=3600
< Cache-Control: stale-while-revalidate=10
< Cache-Control: stale-if-error=86400
< Link: <http://www.stevenchuob.tk/wp-json/>; rel="https://api.w.org/"
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
{ [976 bytes data]
* Connection #0 to host stevenchuob.asuscomm.com left intact

post-60 represents the new post I made. I added some debug so here is what Purgely is doing after I added this new post.

Purgely Purge Log : 2016/06/15 (Wed) 18:38:25 https://api.fastly.com/service/3Th8Drsnfr220zDbyqUTgY/purge/post-60 Array
(
    [headers] => Array
        (
            [content-type] => application/json
            [content-length] => 47
            [accept-ranges] => bytes
            [date] => Wed, 15 Jun 2016 18:38:25 GMT
            [x-varnish] => 418490055
            [via] => 1.1 varnish
            [connection] => close
        )

    [body] => {"status": "ok", "id": "230-1465979820-62972"}

Are you doing anything special on your homepage outside of displaying the latest posts? Frequently, homepages utilize custom queries to pull in collections of posts outside the latest posts. If you are doing this, those post IDs will not be included in the surrogate keys. The plugin has no awareness of custom functionality so it cannot add those for you. If this is the case for you, there is a method for adding additional keys and I can help you with that.

i'm using a free theme that display all the post including the latest one.

Regards,
Steven

@tollmanz
Copy link
Collaborator

Thanks @schuob! I talked this over with Simon from Fastly and there is another condition that needs to be handled here. He is going to start work on a patch.

simonwistow added a commit to fastly/purgely that referenced this issue Jun 15, 2016
Purge the parent id if the post is a revision.

Fixes CondeNast#27
@schuob
Copy link
Author

schuob commented Jun 15, 2016

@tollmanz yup - I worked with simon on it already we got this squared away. By the way I am also from Fastly. Thanks for this plugin it's been awesome working with it on my wordpress install.

--Steven

@schuob schuob closed this as completed Jun 15, 2016
@tollmanz
Copy link
Collaborator

Haha...I did not realize that you were with Fastly. Please let me know of any issue you might experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants