• Hello,

    I am developing a WordPress plugin that uses a custom REST API endpoint to deliver content in a cache-safe way. The endpoint is: wp-json/qotd/v1/today

    The plugin intentionally sets the following HTTP headers via PHP (WP_REST_Response):

    Cache-Control: public, max-age=X, must-revalidate
    Expires: [midnight of current day]

    I have tested this under the following conditions – the behavior is identical in all cases:

    • REST API caching explicitly disabled
    • /wp-json/qotd/ added to “Do Not Cache URIs”
    • Browser Cache enabled
    • Browser Cache disabled

    In every case, LiteSpeed replaces the Cache-Control header set by PHP with its own no-cache directive: Cache-Control: no-cache, must-revalidate, max-age=0, no-store, private

    — My Questions —

    1. Is this hardcoded behavior for all /wp-json/ endpoints?
    2. Is there any way to make LiteSpeed respect and pass through the original Cache-Control header set by PHP for a specific REST endpoint?
    3. Other plugins (e.g. SwiftAI) appear to have an option to respect existing Cache-Control headers – is there a similar mechanism available?

    Thank you for your help.
    Dieter

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.