• Resolved blindpet

    (@blindpet)


    Hector, I use Varnish and cache my whole site. To prevent having to refresh the entire Varnish cache every time I make a new post I have ajaxified Recently and Popular Posts. I also enabled caching for 1 day. Now my question is, is it not possible to combine these?

    I see as visitors come that MySQL and PHP are being used for each visit, before when I didn’t ajaxify the webserver was rarely ever hit. Is there some way to allow it ajax and caching to work more intelligently so that PHP and myql are only used to refresh the cache every 1 day (or what I have specified), while retaining the benefits of ajax so I don’t have to refresh the whole site?

    https://wordpress.org/plugins/recently/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    What do you mean with “combine these”? Both the Ajaxify Widget feature and WPP’s / Recently’s caching feature should work together without problems, but I’m not sure I understood your question correctly 😛

    Thread Starter blindpet

    (@blindpet)

    Before when I didn’t ajaxify an only used the Cache option, I could monitor my site using top on Linux. MySQL and Apache where almost never active.

    Since I switched to ajaxify I can see MySQL being used on every visit which will slow down load times.

    So to me it seems caching and ajaxify are not working together. If I use ajaxify it will use MySQL no matter what even if I have set caching to 1 day.

    Plugin Author Hector Cabrera

    (@hcabrera)

    I’ll try to clear your doubts a bit.

    Before when I didn’t ajaxify an only used the Cache option, I could monitor my site using top on Linux. MySQL and Apache where almost never active.

    Of course, that’s to be expected. What Varnish does is serve static HTML files, so the amount of requests to PHP/MySQL are greatly reduced. That’s the whole point of using a caching plugin 😛

    Now, what’s the problem with caching plugins? They also cache stuff that shouldn’t be cached: dynamic contents -such as a popular posts list, o a recent posts list- become static as well and won’t be updated until Varnish recreates its cache again.

    This is where AJAX comes in handy. It helps dynamic sections of your site stay dynamic. And to do that, they make requests to your server to retrieve fresh data. It’s a tradeoff you can’t avoid. It’s either serve static pages with static contents that won’t be updated until Varnish’s cache expires, or serve static pages with dynamic sections that makes requests to your server to stay dynamic.

    Thread Starter blindpet

    (@blindpet)

    OK good we understand each other so far.

    My question then becomes, why can I enable caching for Popular Posts AND ajaxify if ajaxify always hits MySQL then enabling caching for a day with Popular Posts seems pointless. Do you see what I mean?

    My hope was that Popular posts could cache the results for a day while using ajax thereby bypassing MySQL for at least 24 hours and then fetch the fresh data every 24 hours using ajax. This is how I thought they could be combined.

    Plugin Author Hector Cabrera

    (@hcabrera)

    If I use ajaxify it will use MySQL no matter what even if I have set caching to 1 day.

    Ah, about this. The same happens even if the Ajaxify widget feature is disabled. You just don’t notice it because your site also uses a caching plugin. If you disable Varnish, WPP / Recently will still send a request to PHP/MySQL. The difference is that the amount of queries required to build the content is minimal. Read here for more details.

    Thread Starter blindpet

    (@blindpet)

    Thanks for the explanation, does using redis object cache have any influence on ajaxified widgets?

    Plugin Author Hector Cabrera

    (@hcabrera)

    To be honest, I don’t know for sure.

    What I know about Redis is that it’s similar to Memcache, and that both are used to store small data chunks (strings, objects) in server’s memory. A RAM-based cache, so to speak.

    I imagine that it will affect any widgets the same way as Varnish does: dynamic content will be made static until the cache expires. Ajaxified widgets / scripts, on the other hand, should work just fine unless Redis also caches database queries / objects. Under such situations, they won’t display new content until Redis refreshes its cache.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Combine ajaxify and caching’ is closed to new replies.