SatelliteWP / rocket-nginx

Rocket-Nginx is a Nginx configuration that makes WP-Rocket even faster by serving static pages directly without loading WordPress or PHP.
MIT License
579 stars 129 forks source link

index-mobile-https.html check is missing when mobile is on #171

Closed NizarBlond closed 2 years ago

NizarBlond commented 2 years ago

Describe the bug Not bypassing WordPress when mobile option is active.

Versions What version of Nginx are you using ? v1.21.1 What version of Rocket-Nginx are you using ? latest What version of WP Rocket are you using ? latest Are you using Nginx as a reverse proxy (with Apache for instance) ? PHP-FPM

To Reproduce

I've activated the mobile option and I can verify that .mobile-active is there.

That's my cache folder of the homepage: -rw-r--r-- 1 mysite mysite 0 Dec 16 15:10 .mobile-active -rw-r--r-- 1 mysite mysite 142209 Dec 16 15:10 index-https.html -rw-r--r-- 1 mysite mysite 21337 Dec 16 15:10 index-https.html_gzip -rw-r--r-- 1 mysite mysite 142226 Dec 16 15:10 index-mobile-https.html -rw-r--r-- 1 mysite mysite 21341 Dec 16 15:10 index-mobile-https.html_gzip

In the generated nginx config, you have the following documentation which is wrong:

# File/URL to return IF we must bypass WordPress
# Desktop: index.html
# Gzip:    index.html_gzip
# HTTPS:   index-https.html
# Mobile:  index-mobile-https.html

You are not considering this option at all. It should be something as follows

set $rocket_file_start "index$rocket_https_prefix";
if (-f "$rocket_mobile_detection") {
    set $rocket_file_start "index-mobile$rocket_https_prefix";
}

But then, it confuses me later when you have the following code as you skip the mobile cached.

if (-f "$rocket_mobile_detection") {
        set $rocket_bypass 0;
        set $rocket_is_bypassed "BYPASS";
        set $rocket_reason "Specific mobile cache activated";
}

Please let me know whether this is a bug, and otherwise; explain why you skip the mobile option.

maximejobin commented 2 years ago

There is no way for Rocket-Nginx to detect the device (is it a mobile or desktop?). Therefore, we let WordPress/WP Rocket manage it.