Skip to main content
100%

Gist 367a00c4facccefe2f33a0ef0cd374eb

✓ Published0🌍 Public
KKopylovVitalik
Last edited Oct 8, 2020
Created on Oct 8, 2020

This example shows a WordPress site sending HTTP `Last-Modified` headers based on the most recent post modification time. For singular pages and archive views, it extracts `post_modified_gmt` from the current post or the first post in the loop, formats it as an RFC 2822 date, and sends it via PHP’s `header()` function. The code also checks `HTTP_IF_MODIFIED_SINCE` and returns a `304 Not Modified` status for logged-out visitors when the content has not changed, while skipping execution for admin or AJAX requests.

AI-generated description

Similar vizzes