Hindre WP Super Cache å endre HTTP-felt

Når en bruker WP Super Cache så vil ikke nødvendigvis HTTP-felt taes vare på. Kanskje spesielt viktig hvis en ønsker å styre Cache-Control ved hjelp av f.eks. innstikksmodulen Cache-Control.

Når en da kjører f.eks.:

% curl --compressed -sD - -Lo /dev/null "https://aslakr.folk.ntnu.no/2024/01/wp-super-cache-pa-nfs/Code language: Shell Session (shell)

Så vil en før WSC (WP Super Cache) slår inn få følgende:

HTTP/1.1 200 OK
Date: Tue, 09 Jan 2024 10:44:25 GMT
Server: Apache/2.4.52 (Ubuntu)
Strict-Transport-Security: max-age=63072000
Vary: Accept-Encoding,Cookie
X-Pingback: https://aslakr.folk.ntnu.no/xmlrpc.php
Link: <https://aslakr.folk.ntnu.no/wp-json/friends/v1>; rel="friends-base-url"
Cache-Control: max-age=600, stale-while-revalidate=6000
Link: <https://aslakr.folk.ntnu.no/wp-json/webmention/1.0/endpoint>; rel="webmention"
Link: <https://aslakr.folk.ntnu.no/wp-json/webmention/1.0/endpoint>; rel="http://webmention.org/"
Link: <https://aslakr.folk.ntnu.no/wp-json/>; rel="https://api.w.org/"
Link: <https://aslakr.folk.ntnu.no/wp-json/wp/v2/posts/5407>; rel="alternate"; type="application/json"
Link: <https://aslakr.folk.ntnu.no/b/1W7>; rel=shortlink
Content-Encoding: gzip
Content-Length: 13858
Content-Type: text/html; charset=UTF-8

Code language: HTTP (http)

Når WSC har gjort jobben sin vil web-tjeneren svare:

HTTP/1.1 200 OK
Date: Tue, 09 Jan 2024 10:44:37 GMT
Server: Apache/2.4.52 (Ubuntu)
Strict-Transport-Security: max-age=63072000
Vary: Accept-Encoding,Cookie
Cache-Control: max-age=3, must-revalidate
Last-Modified: Tue, 09 Jan 2024 10:44:26 GMT
Content-Encoding: gzip
Content-Length: 13858
Content-Type: text/html; charset=UTF-8

Code language: HTTP (http)

En mangler da diverse Link-felt og får en Cache-Control som er satt noe kort av WSC. For å omgå dette kan en slå på:

Cache HTTP headers with page content.

(eller sette wpsc_save_headers i wp-cache-config.php til 1).

En skal da få noe slikt som dette:

HTTP/1.1 200 OK
Date: Tue, 09 Jan 2024 10:45:11 GMT
Server: Apache/2.4.52 (Ubuntu)
Strict-Transport-Security: max-age=63072000
Vary: Accept-Encoding,Cookie
X-Pingback: https://aslakr.folk.ntnu.no/xmlrpc.php
Link: <https://aslakr.folk.ntnu.no/wp-json/friends/v1>; rel="friends-base-url", <https://aslakr.folk.ntnu.no/wp-json/webmention/1.0/endpoint>; rel="webmention", <https://aslakr.folk.ntnu.no/wp-json/webmention/1.0/endpoint>; rel="http://webmention.org/", <https://aslakr.folk.ntnu.no/wp-json/>; rel="https://api.w.org/", <https://aslakr.folk.ntnu.no/wp-json/wp/v2/posts/5407>; rel="alternate"; type="application/json", <https://aslakr.folk.ntnu.no/b/1W7>; rel=shortlink
Cache-Control: max-age=600, stale-while-revalidate=6000
Content-Encoding: gzip
Content-Length: 13849
Content-Type: text/html; charset=UTF-8
Code language: HTTP (http)

Publisert

i

av

Kommentarer

Ett kommentar til “Hindre WP Super Cache å endre HTTP-felt”

  1. Aslak Raanes avatar

    @aslakr@aslakr.folk.ntnu.no Kode-blokken ser ikke ut til å gå helt fint gjennom.