wpsharks / comet-cache

An advanced WordPress® caching plugin inspired by simplicity.
https://cometcache.com
GNU General Public License v3.0
75 stars 17 forks source link

3rd Party Plugin Compatibility: WooCommerce All in One Currency Converter #707

Open raamdev opened 8 years ago

raamdev commented 8 years ago

A user reports in an private ticket that the WooCommerce All in One Currency Converter plugin does not work with Comet Cache.

The plugin should take advantage of the Comet Cache Dynamic Version Salt feature to automatically create separate caches for each currency.

Dev49net commented 8 years ago

Hi there, In order to have the compatibility enabled, user needs to go to Advanced section in plugin settings and enable "Currency switching with page caching support". That will add additional parameter to the URL. This is the solution discussed here - https://github.com/woothemes/woocommerce/issues/7939 It is used natively in WooCommerce to make its geolocation feature compatible with cache plugins. I have used the same approach to display same products with different currencies - by differentiating the URL. I am aware that adding a parameter to the URL is not the most convenient solution, as it seems that many cache plugins are using other methods to allow dynamic caching. This is something I am going to look into in the future. Ultimately, the best approach would be to use dynamic caching and only use the URL parameter as the fallback, but it makes things quite complicated. It it something that is on my todo list, but checking which cache plugin is currently active to use the appropriate cache-support method is not an easy process when I can't use PHP to do this.

Daniel

raamdev commented 8 years ago

@Dev49net I've posted a reply regarding this issue here: https://github.com/woothemes/woocommerce/issues/7939#issuecomment-193921578

raamdev commented 8 years ago

Forking some discussion from https://github.com/woothemes/woocommerce/issues/7939:

@daigo75 @Dev49net Thank you both for your input here. :smile: A big part of building WordPress plugins is making sure that they play nicely with other plugins. Caching plugins have a unique role in that they are generally loaded before any other WordPress plugin.

Comet Cache makes it possible for other plugins (and themes) to 'hook into' the caching process early on using a Dynamic Version Salt, however I'm wondering if an easy way to improve support for plugins that use cache-compatible query strings would be to maintain a compatibility list inside the cache plugin, so that for example if @Dev49net's plugin was active Comet Cache could automatically detect that and allow caching for URLs that contained only the ?c=XXXXXX query string.

Anyway, I think this is getting to be off-topic for this specific GitHub issue so I'm going to fork this discussion over to https://github.com/websharks/comet-cache/issues/707.

daigo75 commented 8 years ago

@raamdev I would not recommend to go that way. While it's true that plugins should play nicely with each other, I realised that trying to add explicit support for dozens of plugins is the wrong way to do it. That is

The most elegant approach is what you have already adopted in Comet Cache: keep a generic logic in place, and make it extensible using caching modules. None of the existing plugins will have to be aware of the other, and the advanced caching module will be the one that passes the data from one to the other.

Simple, elegant and efficient example of loose coupling.

raamdev commented 8 years ago

@daigo75 I'm not necessarily proposing that we build in specific integration for each plugin, but we could do something like maintain a directory of modular integrations, e.g., AC Plugins that can be contributed by various plugin authors who want to make sure the caching plugin handles their specific plugin the proper way.

daigo75 commented 8 years ago

@raamdev in such case, you already have mine. :smile: