Skip to content
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 without using filesystem #116

Closed
paulschreiber opened this issue Feb 23, 2018 · 5 comments
Closed

Cache without using filesystem #116

paulschreiber opened this issue Feb 23, 2018 · 5 comments

Comments

@paulschreiber
Copy link
Contributor

WordPress VIP support will not allow this plugin to be used until this issue is addressed:

helpers/cache.php

This cache mechanism must be rewritten as it relies on the filesystem

@yo35
Copy link
Owner

yo35 commented Feb 25, 2018

In RPB Chessboard, caching is used to store some dynamically generated CSS code, that is not likely to change often, but that cannot be defined in a fully static way. The idea is to avoid having to much CSS inlined each time a page is generated.

Do you have a suggestion to achieve this in a more proper way?

@paulschreiber
Copy link
Contributor Author

WordPress has its own built-in caching method. You can use wp_cache_set() / wp_cache_get() for caching.

Complete documentation is here:
https://codex.wordpress.org/Class_Reference/WP_Object_Cache

@yo35
Copy link
Owner

yo35 commented Feb 25, 2018

But WP_Object_Cache is not intended for file caching, am I wrong?

@paulschreiber
Copy link
Contributor Author

WP_Object_Cache is a key/value store. You can use it for many things. I've created a PR uses the object cache.

If you're concerned about inlining the CSS, I can rewrite this so we generate distinct, cacheable URLs for each cached CSS blob and enqueue them.

@yo35 yo35 closed this as completed in #125 Mar 11, 2018
@yo35
Copy link
Owner

yo35 commented Mar 11, 2018

It seems that the function wp_add_inline_style( $handle, $data ) does nothing if wp_enqueue_style( $handle, ...) has not been called previously, with the same $handle. I've fixed your PR to account for this pitfall in the WP API...

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

No branches or pull requests

2 participants