Automatically Generate Cache For The Salt of Mobile Device Users

Hi I am using Comet Cache Pro as well as Autooptimize plugin to speed up our blog http://mediamaker.tips/ and receive high evaluation from Google PageSpeed Insights. And I must to say this combination works perfectly for me. In some cases I got even 100 points.

We have no much traffic for now, that’s why I am very happy with the Pro feature: Auto-Cache Engine. It helps us to guarantee the speed for each and every user.

Another extremely useful Pro version we are using is: Dynamic Version Salt. It is needed because our site mobile mode is partially Responsive (CSS works) and partially Adaptive (PHP works). So we need to generate separate cache for Adaptive Mobile version and the technique is well described here:

THE QUESTION:
Is it possible to automatically generate cache also for Mobile users? As seems Auto-Cache Engine works only for standard mode.

We would be incredibly happy if you could suggest us any solution or workaround.

Many thanks for sooooo useful plugins
BR
Alex J

@trancedrumer Glad to hear you’re enjoying Comet Cache. :slight_smile:

I love the idea of being able to have the Auto-Cache Engine flexible enough to also cache the mobile version of the site, but unfortunately there isn’t any reliable way to build such a feature so that it would work across many sites. For example, most mobile themes use the User-Agent string to determine when the mobile version should be loaded, but what if a different version of the theme is loaded for different User-Agents (e.g., one version for iOS devices, another for Andriod; or one version for tablets and another version for phones)? In that case, you’d need to have the Auto-Cache Engine run once for each User-Agent string… that gets very resource-intensive (which defeats the primary purpose of Comet Cache, which is to reduce server resources and speed things up for your visitors).

Hi,

@raamdev

Well, I think Cache plugin main goal is speed and the reducing server resources is secondary.

Also, not every website have hundreds of pages to cache. For us this number is bellow 300 and around 30 Mb. So there is no resource issue to worry about.

Plus, In our case (I believe many bloggers have similar config) we have only 2 different HTML codes generated by PHP, one for Touch users and second for mouse users. Rest is just responsive. So only 2 versions of cache is needed. And as I can see now it is possible to specify User Agent in the settings - but only one.

So can you help me to configure second crone job for another user agent?.Where existing code for hook _cron_comet_cache_auto_cache is placed? I could make a copy with another User Agent.

2 More things found meanwhile:

  1. With WP Control I can see that Auto Cache hook and cleanup hook are launching every minute. Is it a bug or real work. As when cache is generated seems it is not cleaned up. Bu generating itself is not consistent - it is not working every 15 minutes.

  2. When autocache is working is it rebuild the cache for outdated files? If so - marking all cache outdated would be extremely useful- as all cache is staying and after 15 minutes it is replaced by new one - and no any time without a cache. This would be useful for many case when it is ok to wait 15 minutes to make content refresh to new version.
    So the question is it possible technically.

Thank you

BR
Alex J

So can you help me to configure second crone job for another user agent?.Where existing code for hook croncomet_cache_auto_cache is placed? I could make a copy with another User Agent.

I recommend opening a feature request for that here.

With WP Control I can see that Auto Cache hook and cleanup hook are launching every minute. Is it a bug or real work. As when cache is generated seems it is not cleaned up. Bu generating itself is not consistent - it is not working every 15 minutes.

How are you determining that it’s launching every minute? WP Crontrol shows both cron events running as expected:

When autocache is working is it rebuild the cache for outdated files? If so - marking all cache outdated would be extremely useful- as all cache is staying and after 15 minutes it is replaced by new one - and no any time without a cache. This would be useful for many case when it is ok to wait 15 minutes to make content refresh to new version.
So the question is it possible technically.

Yes, the Auto-Cache Engine rebuilds expired cache files. I’m not sure that I understand the rest of your question.

In Cron Events I always see the until time is less than a minute

it is similar to this found here: https://wordpress.org/plugins/comet-cache/changelog/

Bug Fix: In some scenarios the Cron Event that cleans up expired cache files (_cron_comet_cache_cleanup) would never run, or the Next Run time would constantly reset to 1 minute away from running every time a page was reloaded. We suspect this is a race condition and in attempt to work around this issue we now skip all of our Cron-related checks if Cron is currently in the middle of running a process. Props @xberg and @lkraav for help reporting. See Issue #653.

If Auto-Cache Engine rebuild Expired cache files then I can’t see much sense in deleting cache files. What would make sense is changing expired date so when next time ACE visit those files it just rebuild them.
This will ensure that there is no time frame when your server has no warm cache. So no one will face in slow loading.

So - is there any command or tool that can make cache expired?

Is Hook Name _ cron_comet_auto_cache a PHP function? If yes, where is it placed?

Thank you
Alex J

That only makes sense if you expect your cache files to be rebuilt every single time the Auto-Cache Engine runs, which doesn’t make sense at all in most cases. The Auto-Cache Engine runs every 15 minutes by default. Most pages on most WordPress sites will not change every 15 minutes — that’s why our default expiration time is 7 days. Many site owners set this even longer — 30 days or 90 days.

If a cached page does change for some reason (for example, if an already-published Post/Page was edited and updated in the WordPress Dashboard), Comet Cache will automatically detect that change and clear the cache file (and any other cache files associated with that page) so that it remains up-to-date. You won’t need to wait until the cache file expires to see the changes — Comet Cache automatically expires the cache file for any pages that change.

In the event that you do something like change your WordPress Theme (which would affect all pages on the site), Comet Cache detects that kind of change too and clears all cache files from the entire site to make sure that whatever gets served to visitors is current.

Unfortunately no, there is not.

Yes, that attaches to this:

Hi @raamdev,

thank you for your clarifications.

Regarding cache expiring - I think you got me wrong. The Idea: For example system set cache expire date Today()+7. Then, new post is published and instead of clearing all cache - system will set expiration date = Today() for all cached files. So next time Auto Cache Engine visit cached files - it rebuild them.
But, if you say there is no way to change the expire date, then no way to have such a beautiful dream :slight_smile:

I tried to warm cache using wget command and got this comment

Comet Cache is NOT caching this page, because [current IP address] === $_SERVER['SERVER_ADDR']; i.e. a self-serve request. DEVELOPER TIP: if you are testing on a localhost installation, please add define('LOCALHOST', TRUE); to your /wp-config.php file while you run tests :slight_smile: Remove it (or set it to a FALSE value) once you go live on the web.

Is there a workaround on this, or we must to find another server?

Thanks
BR
Alex J

actually I defined

define(‘LOCALHOST’, TRUE);

and it worked just fine, and seems does not break my site :slight_smile: