-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Enqueued Scripts not present in cached markup #160
Comments
I just modified the init method ( add_action( 'template_redirect', array( __CLASS__, 'manage_cache', ), 0 ); to just calling self::manage_cache(); And because this phase is damn early and a lot can happen inbetween, I added a public static function set_cache( $data ) {
// [...]
if ( ! self::_skip_cache() ) { // <-- here
call_user_func(
array( self::$method, 'store_item', ),
...
);
} This solves the problem for all of my test sites. Question: |
I also stepped into this trap - the link to my js file becomes not part of the cached html file. Sorry - due to lack of experience I can not assess Your proposal. But nevertheless I would like to ask when You expect a update of cachify. A plugin listed in WordPress Plugin Directory with attributes like: |
Normally, the output buffer passed to
If this is not the case on your website, then perhaps something is forcing the output buffer to flush earlier? Since your problem seems to be gone when you activate output buffering (= call
I would say it is safe, but it comes with a penalty of output buffering being always on, even if the output buffer is later discarded because of positive "skip cache" check. |
As I discovered now this was not an issue with a single page I had to exclude from caching some time ago, but now messes up with a complete theme of mine.
We initialize the cache in the
template_redirect
phase and pass our callback to the output buffer.Now imagine some scripts added in the footer using code like this:
(btw. this is the way default themes like TwentySeventeen and many plugins popular do the job)
The enqueued script is not present in the markup when the OB callback is triggered, so it is not cached.
Issue present in 2.2.4, 2.3-beta.1 and GH master. Tested with WP 4.9.8 and current 5.0 snapshot.
The text was updated successfully, but these errors were encountered: