-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache Global-Styles #25680
Cache Global-Styles #25680
Conversation
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to see the relation between caching and our extensibility solution. We may also need to have a solution to allow the browser caching of things in theme.json. Currently, that is not possible because we output everything as inline styles send on every page request. But what we have in this PR is better that what we have now so I guess we can merge it :)
if ( $can_use_cached ) { | ||
|
||
// Check if we have the styles already cached. | ||
$cached = get_transient( 'global_styles' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we have extensibility we need to document very well what plugins can do. If a plugin changes global styles depending on the page, for example, the caching solution makes things not work well because we have a global cache, so the value will be equal on all pages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to see the relation between caching and our extensibility solution. We may also need to have a solution to allow the browser caching of things in theme.json. Currently, that is not possible because we output everything as inline styles send on every page request. But what we have in this PR is better that what we have now so I guess we can merge it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to see the relation between caching and our extensibility solution. We may also need to have a solution to allow the browser caching of things in theme.json. Currently, that is not possible because we output everything as inline styles send on every page request. But what we have in this PR is better that what we have now so I guess we can merge it :)
Is this working correctly? Checking the |
I deleted the persistent transient, and now the new generated transient is set with an expiration date, so I'm no longer having issues. |
Description
Adds a 1-minute cache to global styles - see #25678
On high-traffic sites this will avoid costly calculations and improve performance. Calculating styles once/minute is OK, calculating them on each page-request not so much. 😆
Styles will only be cached if we're not in debug more and not in the editor.
Checklist: