Skip to content

Cache control directives stale-while-revalidate and stale-if-error for frontend do not get sent even when Ghost config is set #21886

Open
@JamesMarino

Description

Issue Summary

Cache control directive stale-while-revalidate and stale-if-error for frontend do not get sent as header directives even when passed in configuration values for caching.frontend.staleWhileRevalidate and caching.frontend.staleIfError.

Please note code has not been allowed specifically for staleIfError cache control directive config but should be included due to its usage in conjunction with staleWhileRevalidate. Please see MDN docs here on Cache-Control for further information.

Initial changes have been made here it seems #15734 and I can submit a fix shortly as a PR.

Also, documentation has also not been updated for caching, whereabouts can changes to documentation be submitted?

Steps to Reproduce

  1. Initial Setup of the Ghost site locally
yarn setup
  1. Run the site with a custom maxAge to ensure environment variables are being passed through and with a custom staleWhileRevalidate value to show that this directive is not being received in the Cache-Control header
export caching__frontend__maxAge=1800
export caching__frontend__staleWhileRevalidate=604800
yarn dev
  1. Send off a request to the home page and initial post to show it's not being sent
curl -s -i http://localhost:2368/ | grep -i "Cache-Control"

# Output:
# Cache-Control: public, max-age=1800
  1. Try another post page as well
curl -s -i http://localhost:2368/coming-soon/ | grep -i "Cache-Control"

# Output:
# Cache-Control: public, max-age=1800

Ghost Version

v5.105.0

Node.js Version

v18.20.4

How did you install Ghost?

Local Development on MacOS 15.1.1

Database type

MySQL 5.7

Browser & OS version

No response

Relevant log / error output

No response

Code of Conduct

  • I agree to be friendly and polite to people in this repository

Metadata

Assignees

No one assigned

    Labels

    bug[triage] something behaving unexpectedly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions