Hello friends, I was able to solve the problem.
Follow the steps below to solve the problem
Step 1: Go to the following path and open the nginx.conf file
/www/server/nginx/conf/nginx.conf
At the beginning of the http { loop, copy the following content
map $http_user_agent $mobile_request {
default fullversion;
"~*ipad" mobileversion;
"~*android.*mobile" mobileversion;
"~*iphone" mobileversion;
"~*ipod.*mobile" mobileversion;
"~*BlackBerry*Mobile Safari" mobileversion;
"~*BB*Mobile Safari" mobileversion;
"~*Opera.*Mini/7" mobileversion;
"~*IEMobile/10.*Touch" mobileversion;
"~*IEMobile/11.*Touch" mobileversion;
"~*IEMobile/7.0" mobileversion;
"~*IEMobile/9.0" mobileversion;
"~*Firefox.*Mobile" mobileversion;
"~*webOS" mobileversion;
}
Now find the value below
fastcgi_cache_key "$scheme$request_method$host$request_uri";
and replace it with the value below
fastcgi_cache_key "$scheme$request_method$host$request_uri$mobile_request";
Now save the changes and close the file
Step 2: Now go to the following path
/www/server/nginx/conf
In this path, you should find the enable-php-{x}-wpfastcgi.conf file and edit it.
Note: The {x} variable is your php version and edit it based on the version that is active on your server.
For example, I use php version 8.1 and I edit the file enable-php-81-wpfastcgi.conf
When you open this , Add the following two variables at the beginning of the file
set $var_desktop "full version";
set $var_mobile "mobile version";
Then, Find the codes below
location ~ /purge(/.*) {
allow 127.0.0.1;
deny all;
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
Replace it with the value below
location ~ /purge(/.*) {
allow 127.0.0.1;
deny all;
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1$var_desktop";
}
location ~ /mpurge(/.*) {
allow 127.0.0.1;
deny all;
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1$var_mobile";
}
Step 3: Now go to Nginx settings and restart it
Dear aapanel professors, with these changes, the problem was solved and in the section
/dev/shm/nginx-cache/wp
Caches are saved and the interference between mobile and PC is gone.
I just have a few questions
Is this method correct and principled?
How do I make sure the cache system is working properly?