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

Enable Memcached fallback for non-nginx #141

Open
stklcode opened this issue Jul 14, 2017 · 3 comments
Open

Enable Memcached fallback for non-nginx #141

stklcode opened this issue Jul 14, 2017 · 3 comments

Comments

@stklcode
Copy link
Contributor

I was wondering about why the print_cache() methods for the memory backends have been left empty instead of doing something useful like .. let's say print the cache... The memcached->get() is called anyway a couple of lines earlier, but the result is just ignored. Can't imagine any reason for that. (shouldn't be queried if not used).

I ran a couple of tests on a real-world site, enabled memcached without the nginx config and added a few lines to the backend. Processing time dropped from ~180ms to ~60ms using Memcached through PHP (~65ms for DB cache), so I think it's worth enabling this for users not able to reconfigure their server or not using nginx at all.

Of course the server module performs far better than taking the loop through PHP and this should be the preferred way. The setup information can still be displayed if using nginx with a note on performance.

Makes debugging a little harder, so maybe one could add a hint in the HTML comment (if detailed signature is enabled) to point out which path is actually used.

I started working on this in my fork to ge a smooth solution. So if we decide to add this in future releases (not in 2.3.0 I believe), it should be about ready for testing.

Open for discussion.

@chesio
Copy link
Contributor

chesio commented Jul 14, 2017

Just one note to your benchmarks (I assume you are running them with code from master branch). I made a similar benchmarks for HDD cache before I submitted #98 and there's been little improvement until #93 has been merged. In other words, current stable version of Cachify does not benefit from these fallbacks that much, because cache is printed in template_redirect hook that is run just before theme template file is loaded. That's perhaps why the respective methods have been left empty.

I'm mentioning it, cause I realized that printing cache early (ie. change introduced in #93) is not backwards compatible in some scenarios (see #138), so I guess we should decide first, whether we keep it like it is, try to minimize possible back-compat issues in some way or revert the change completely.

Makes debugging a little harder, so maybe one could add a hint in the HTML comment (if detailed signature is enabled) to point out which path is actually used.

This is quite important I'd say. I haven't done it for HDD cache yet, cause there's no straightforward solution.

@stklcode
Copy link
Contributor Author

stklcode commented Jul 14, 2017

Absolutely right, thanks for the reminder.

Of course my tests are based on the development state (not on a production site, but a staging version), I'm not going to optimize legacy code.

This is quite important I'd say. I haven't done it for HDD cache yet, cause there's no straightforward solution.

Actually there is one now. With the $sig_detail parameter passed to the print_cache() method (introduced in #108), the information, if a user want's to see additional details in the HTML comment (e.g. number of DB queries for DB cache) is present. This activated, the fallback prints can just add a single line to the cached content, just before exit;.
We should decide (uniform for every method), if and what should be printed there. No internal data, maybe just the current time...

@chesio
Copy link
Contributor

chesio commented Jul 20, 2017

This activated, the fallback prints can just add a single line to the cached content, just before exit;

You mean adding an extra comment after closing html tag? Something like:

</html>
<!-- Cachify: cache file served via PHP -->

This could work :)

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

No branches or pull requests

2 participants