Skip to content

Transient Caching. Minor Privacy Enhancement#14

Open
greg-randall wants to merge 2 commits intoProgressPlanner:mainfrom
greg-randall:main
Open

Transient Caching. Minor Privacy Enhancement#14
greg-randall wants to merge 2 commits intoProgressPlanner:mainfrom
greg-randall:main

Conversation

@greg-randall
Copy link

@greg-randall greg-randall commented Feb 16, 2026

Context

I added transient caching for markdown output and hid the alternate link tag for password-protected posts.

  • The markdown rendering pipeline (HTML conversion, frontmatter generation) runs on every request. Caching skips that work when the post hasn't changed.
  • Password-protected posts were exposing a <link rel="alternate"> tag in the HTML head, which reveals that a markdown endpoint exists for gated content.

Summary

This PR can be summarized in the following changelog entry:

  • Cache rendered markdown output using transients (24h default), invalidated when the post is updated.
  • Hide <link rel="alternate"> tag in the HTML head for password-protected posts.
  • Add markdown_alternate_cache_expiration filter for adjusting cache duration.

Relevant technical choices:

  • Cache validation checks post_modified rather than relying only on time-based expiry, so post edits show up without waiting for the cache to expire.
  • Uses the transients API rather than the object cache directly. This works on any host, even without a persistent object cache.
  • Uses post_password_required() for the visibility check because it respects the cookie-based password flow- it returns false if the user has already entered the password.

Test instructions

  1. Visit any post or page at its .md URL and reload; second request should be served from cache.
  2. Edit the post, save, and reload the .md URL, content should update.
  3. Set a password on a post and verify the <link rel="alternate"> tag is gone from the HTML source. Remove the password and confirm it reappears.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Block/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Documentation

  • I have written documentation for this change.

Quality assurance

  • I have tested this code to the best of my abilities.
  • I have added unit tests to verify the code works as intended.
  • I have checked that the base branch is correctly set.

Fixes #

- Add transient caching to ContentRenderer to reduce CPU load on high-traffic sites
- Implement post-modified validation to ensure cache freshness
- Hide alternate link discovery tags for password-protected content to improve privacy
- Add 'markdown_alternate_cache_expiration' filter for developer control
- Bump version to 1.1.0
- Add spaces inside parentheses for function calls and control structures
- Use array() syntax for transient data to match WP standards
- Add DocBlock documentation for 'markdown_alternate_cache_expiration' filter
- Reorder comparison in cache validation for better readability
@jdevalk
Copy link
Member

jdevalk commented Feb 17, 2026

Consolidation note: overlaps with #11 in ContentRenderer. Recommend choosing a primary renderer PR and rebasing the other after merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants