wordpress-nginx
wordpress-nginx copied to clipboard
Caching for mobile?
Thanks for organizing this documentation! Very helpful.
We currently have some issues with responsiveness in mobile devices, i.e., some mobile-specific menus or features would not appear correctly. How can we make separate cache for mobile? See examples: https://docs.wp-rocket.me/article/708-mobile-caching https://crocoblock.com/troubleshooting/articles/cannot-make-jetmenu-mega-menu-mobile-responsive/
Thank you!
I discovered the following pages and add some conf line accordingly.
# https://miteshshah.github.io/linux/nginx/how-to-setup-separate-nginx-fastcgi-cache-for-mobile-and-desktop-users/
# https://serverfault.com/questions/150057/nginx-caching-per-user-agent
set $mobile_request 'desktop';
if ($http_user_agent ~* '(iPhone|iPod|mobile|Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile)') {
set $mobile_request 'mobile';
}
# The key to use when saving cache files, which will run through the MD5 hashing algorithm.
fastcgi_cache_key "$scheme$request_method$host$request_uri$mobile_request";