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

Enabling caching prevents previously published pages being unpublished by changing to draft #1551

Open
gpoole opened this issue Nov 11, 2024 · 4 comments
Labels

Comments

@gpoole
Copy link

gpoole commented Nov 11, 2024

Version

1.22.1

What did you expect to happen?

After changing a previously published page to draft again, I expected it to no longer be accessible on the site.

What actually happens?

The page is still accessible at the public URL. Looking at the response when accessing the unpublished page at its public URL, I see the fastcgi-cache header is always STALE. This is true even after waiting for over the default 30s cache duration.

If the cache is disabled, after changing a published page back to a draft, the public URL returns a 404 as expected.

The same issue looks to have been discussed in a previous support forum request but I think it's a bug as I would expect the caching config to work as expected by default in this case.

Steps to reproduce

  1. Provision site with cache enabled with default settings e.g.
wordpress_sites:
  example.com:
   # ...
    cache:
      enabled: true
  1. Create and publish a page e.g. /test.
  2. Access the page at example.com/test
  3. Unpublish the page via "Switch to draft"
  4. The page is still accessible at example.com/test

System info

Ubuntu 22.04

Log output

No response

Please confirm this isn't a support request.

Yes

@gpoole gpoole added the bug label Nov 11, 2024
@gpoole gpoole changed the title Enabling caching prevents previously published pages being changed to draft Enabling caching prevents previously published pages being unpublished by changing to draft Nov 11, 2024
@gpoole
Copy link
Author

gpoole commented Nov 11, 2024

Would it make sense to change the standard NGINX config by adding any to fastcgi_cache_valid and adding a fastcgi_ignore_headers setting as mentioned in the support discussion I referenced earlier on this?

@gpoole
Copy link
Author

gpoole commented Nov 11, 2024

Some alternative configurations that address this issue are also discussed on the NGINX issue tracker: https://trac.nginx.org/nginx/ticket/1233#comment:8

@swalkinshaw
Copy link
Member

swalkinshaw commented Nov 11, 2024

Nginx docs say:

If only caching time is specified then only 200, 301, and 302 responses are cached.

Setting it to any is risky because it can have the opposite problem where temporary error states could be cached for 30s.

I think it might be possible to skip the cache entirely if Cache-Control: no-cache exists. You could try adding this to wordpress-site.conf.j2:

map $upstream_http_cache_control $skip_cache {
    "~*no-cache" 1;
   # or
   # no-cache   1;
}

Would you be able to try that?

@strarsis
Copy link
Contributor

strarsis commented Nov 23, 2024

Somehow related: #1513 (the nginx configuration map).

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

No branches or pull requests

3 participants