Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#34832 closed defect (bug) (fixed)

REST API does not send nocache headers on authenticated requests

Reported by: joehoyle Owned by: rmccue
Priority: normal Milestone: 4.4
Component: REST API Version: 4.4
Severity: normal Keywords: has-unit-tests has-patch commit
Cc: Focuses:

Description

Core typically sends nocache headers on all auth'ed responses, as in wp, admin-ajax, etc. Because the REST API infrastructure is hooked in pre-wp, we should be setting this ourselves.

I'd recommend we get this fix in 4.4 given the implications.

Attachments (2)

34832.diff​ (3.3 KB ) - added by joehoyle 11 years ago.
34832.2.diff​ (3.2 KB ) - added by joehoyle 11 years ago.

Download all attachments as: .zip

Change History (13)

#1 @rmccue
11 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → 4.4
  • Owner set to rmccue
  • Status new → accepted

#2 @markjaquith
11 years ago

What are the criteria? Should it be done via a hook, so it can be unhooked?

#3 @joehoyle
11 years ago

@markjaquith the criterium is is_user_logged_in(). I think we'll need to add it directly, but can pass it through a filter to allow overriding (and also sending no-cache headers on un'authed requests if the developer wanted to). Patch incoming.

This ticket was mentioned in ​Slack in #core by joehoyle. ​View the logs.


11 years ago

#5 @joehoyle
11 years ago

  • Keywords has-unit-tests has-patch added; needs-patch removed

This ticket was mentioned in ​Slack in #core by wonderboymusic. ​View the logs.


11 years ago

#8 @wonderboymusic
11 years ago

  • Keywords commit added

#9 @wonderboymusic
11 years ago

+1 from me

#11 @wonderboymusic
11 years ago

  • Resolution → fixed
  • Status accepted → closed

In 35773:

REST API: Core typically sends nocache headers on all auth'ed responses, as in wp, admin-ajax, etc. Because the REST API infrastructure is hooked in pre-wp, we should be setting this ourselves.

Adds unit tests.

Props joehoyle.
Fixes #34832.

Note: See TracTickets for help on using tickets.