Skip to content

Prevent updating transient when just previewing post and prime cache upon post-save #695

@westonruter

Description

@westonruter

Currently the syntax-highlighted markup gets cached in a transient every time a modification is made, unless in development mode:

if ( ! DEVELOPMENT_MODE ) {
set_transient( $transient_key, compact( 'content', 'attributes' ), MONTH_IN_SECONDS );
}

This can cause quite a few throw-away transients to build up in the course of editing a post. I suggest we add an is_preview() to the conditions, so it only caches the result when viewing the post in a non-preview context.

It would also be good to warm the cache upon save_post so that a frontend request is less prone to involve a cache miss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions