Starting at 3.16, mobile cache is activated by default
Starting at 3.16, mobile cache is activated by default on new installations following the removal of the Cache tab.
This means two cache files are generated (desktop and mobile) and we need to be able to know if the visitor comes from mobile or not.
This could be tricky as identifying the device is not easy with Ngnix's scripting language.
Could be based on the JSON from Mobile Detect.
hello, with wp rocket pushing "mobile cache" with all the benefits of "Optimize critical images" and "reduce unused css" (which benefits both desktop and mobile total file size) I wonder what the current best caching option is for powerful dedicated hosting?
Have you already decided whether you will improve rocket-nginx (if even possible) to support mobile cache from wp rocket?
I have Cloudflare in front of Nginx which actually sends me CF-Device-Type header which can have either mobile, tablet (or) desktop as a value. Will this be useful in identifying and serving mobile specific cache by Nginx ?
I see WpRocket already has compatibility with CloudFlare APO which I am currently using and have enabled device specific cache there also (as it is recommended by WPRocket)
Cloudflare uses regex defined here https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type Since WPRocket is compatible with Cloudflare can we use such regex ?
we also use cloudflare (pro) together with wprocket
I have made a direct fix in my config file and it seems to pick proper mobile caches with help of CloudFlare CF-Device-Type Header (Need to enable Cache By Device Type in APO)
Leaving it here if someone needs until we have a solution
https://gist.github.com/sriharsha-y/4182b601c2daef407758d90cb3e68fe4
Added below checks & commented out existing mobile cache checks https://gist.github.com/sriharsha-y/4182b601c2daef407758d90cb3e68fe4#file-rocket-nginx-tmpl-L99 https://gist.github.com/sriharsha-y/4182b601c2daef407758d90cb3e68fe4#file-rocket-nginx-tmpl-L166
awesome thank you
Based on Cloudflare documentation, these rules that are incomplete and not perfect could be implemented: https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/
I do not have enough data to know if it covers 99.9% of all requests or if it 85%.
Implementing Mobile Detection perfectly would be nearly impossible using Nginx's scripting language.
I just released version 3.1.0 beta where mobile detection is supported using Cloudflare's regex rules.
This is not perfect as Nginx's scripting does not allow all functions needed for full detection but it should cover the same devices as Cloudflare.
If you can test and let me know if it works well or not, it would be appreciated.
https://github.com/SatelliteWP/rocket-nginx/releases/tag/v3.1.0-beta
Awesome, thank you! I'll let you know as soon as we implemented it!
Desktop works well for us, thank you. What I coudn't test was mobile (as I don't have the right tools on my phone).
@maximejobin thank you for this update!
Mobile detection works well. I have tested a few Android and iOS user agents (using desktop firefox Tools -> Web Developer- > Responsive Design View).
Of course it is not able to detect all mobile browsers. For example at the Android Section at https://deviceatlas.com/blog/mobile-browser-user-agent-strings you can see that there are some Android Browsers that will not be detected currently. The only identifiable string in their user agent would be their browser short name.
You probably don't want to go down the rabbit hole of detecting mobile browser variants and mobile devices. What do you think about keeping on the safe side by :
- Detect desktop browsers (
Windows NT|Macintosh|X11) to serve desktop cache. - Do not serve cache if neither mobile or desktop is detected.
?
What do you think about keeping on the safe side by :
Detect desktop browsers (Windows NT|Macintosh|X11) to serve desktop cache. Do not serve cache if neither mobile or desktop is detected.
The detection regex is in a configuration variable. Therefore, you can edit it if you want!
If I cannot detect that it is indeed a mobile, then it is a desktop. Not serving any file would not make sense to me.