WordPress.org

Make WordPress Core

Opened 6 months ago

Closed 5 months ago

#47396 closed enhancement (fixed)

Cron: Add no cache headers before calling `fastcgi_finish_request()`

Reported by: peterwilsoncc Owned by:
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Cron API Keywords: good-first-bug has-patch
Focuses: Cc:
PR Number:

Description

Calls to wp-cron.php are not intended to be cached.

In the block checking for and running fastcgi_finish_request() adding headers to prevent caching will prevent the DefaultTTL from being used on CDNs such as CloudFlare.

Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0

Attachments (3)

47396.diff (464 bytes) - added by kingkero 5 months ago.
47396-wp_get_nocache_headers.diff (476 bytes) - added by kingkero 5 months ago.
47396-cs.diff (883 bytes) - added by peterwilsoncc 5 months ago.
CS Fixes rquired by wp-cron.php prior to fixing #47396

Download all attachments as: .zip

Change History (9)

#1 @peterwilsoncc
5 months ago

  • Keywords good-first-bug added
  • Owner peterwilsoncc deleted

@kingkero
5 months ago

#2 @kingkero
5 months ago

  • Keywords has-patch needs-testing added; needs-patch removed

added Cache-Control and Pragma header

#3 @peterwilsoncc
5 months ago

  • Keywords needs-refresh added; needs-testing removed

@kingkero Thanks so much for the patch.

You've put the headers in the perfect spot, but it is OK if you use the Expires and Cache-Control headers I noted above?

WordPress has a function nocache_headers() that uses the expires and cache-control headers. nocache_headers() isn't available here but using the same two headers will ensure consistency for WordPress sites.

I've marked this patch as needing a refresh, if you have time that would be great but I (or another person) can pick it up if you don't.

#4 @kingkero
5 months ago

@peterwilsoncc You're very welcome.

I added a new diff with the headers from the wp_get_nocache_headers() method and removed the Pragma, since the other method doesn't set it either

@peterwilsoncc
5 months ago

CS Fixes rquired by wp-cron.php prior to fixing #47396

#5 @peterwilsoncc
5 months ago

In 45559:

Code is Poetry: CS Fixes required in wp-cron.php.

See #47396, #41057.

#6 @peterwilsoncc
5 months ago

  • Keywords needs-refresh removed
  • Resolution set to fixed
  • Status changed from assigned to closed

Closed in 45560 but yours truly made a typo and left the hash of the ticket number. @kingkero your props will still be recorded once 5.3 is released.

In 45560:

(The changeset message doesn't reference this ticket)

Note: See TracTickets for help on using tickets.