Added a facility to make DF_REST_Controller->response emit a cache control header.
What I did
- Added a facility to make
DF_REST_Controller->response
emit a cache control header. - Added documentation for the new facility.
Implications
- Authors of API endpoints that are subclasses of
DF_REST_Controller
can specify a default value for cache expiry of all responses (including error responses). - The value can also be set within individual API methods in that class if required.
Setup
None
How to test
- Code review.
- Check documentation for accuracy and clarity.
- Test with branch
feature/prevent_api_response_caching
in the main Art Money project.- In the admin section, go to your user account screen.
- Delete all client notes and reload, if you already had any.
- Check the
404
response when client notes are loaded, and confirm that it includes acache-control: max-age=0
header. - Remove the value declaration from
api/v1/client_notes.php
and retest, confirming that the404
response now includes nocache-control
header.