Join the community today
Become a Member

Cloudflare 500+ milliseconds saving for www/non-www redirects

Discussion in 'Domains, DNS, Email & SSL Certificates' started by rdan, Sep 1, 2019.

  1. rdan

    rdan Well-Known Member

    4,605
    1,111
    113
    May 25, 2014
    Ratings:
    +1,632
    Local Time:
    8:50 PM
    Mainline
    10.2
    Small tip that can save 500+ms for redirect request.
    Instead of doing your www/non-www redirect on the Server level,
    just do it on Cloudflare Page Rule Instead.

    Sample for www redirect
    upload_2019-9-1_3-33-43.png

    My http to HTTPS redirect is already done by browser HSTS Preload List (local redirect 1ms).

    Test before and after via Browser Network Tab.
    With this option check
    upload_2019-9-1_3-36-46.png
     
    • Informative Informative x 2
  2. eva2000

    eva2000 Administrator Staff Member

    41,350
    9,279
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,236
    Local Time:
    10:50 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    Yes it helps but
    1. 301 redirects are cached at browser level, so subsequent 301 redirects won't hit your server anyway and come from web browser of visitor
    2. HSTS Preload enabled sites also will have redirect to HTTPS done at web browser level.
     
    • Like Like x 1
  3. rdan

    rdan Well-Known Member

    4,605
    1,111
    113
    May 25, 2014
    Ratings:
    +1,632
    Local Time:
    8:50 PM
    Mainline
    10.2
    I do have 65% of visitors that came from search engine and other site, still it helps for 1st time visitor.
    Or linked/bookmark url without www.

    That's why I don't include https redirect.
     
    • Informative Informative x 1
  4. eva2000

    eva2000 Administrator Staff Member

    41,350
    9,279
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,236
    Local Time:
    10:50 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    indeed that is where you'd have the most benefit :)
     
    • Like Like x 1
  5. jcat

    jcat Member

    110
    17
    18
    Jun 21, 2015
    Ratings:
    +44
    Local Time:
    8:50 AM
    That's crazy it takes 500ms for your server to redirect, are you sure nginx was doing the redirect and not WordPress? If you are not redirecting via nginx then yes WordPress is very slow since it requires PHP to process the request, its basically like waiting for a page to load without cache.
     
  6. rdan

    rdan Well-Known Member

    4,605
    1,111
    113
    May 25, 2014
    Ratings:
    +1,632
    Local Time:
    8:50 PM
    Mainline
    10.2
    Not my server but...
    User > Cloudflare > My Server > back to Cloudflare > to User = Takes 600-700+ms usually.

    Without cache/First time visitor.
     
  7. rdan

    rdan Well-Known Member

    4,605
    1,111
    113
    May 25, 2014
    Ratings:
    +1,632
    Local Time:
    8:50 PM
    Mainline
    10.2
    With this implementation, I only got:
    User > Cloudflare > back to User = Takes 40-150 ms usually.
     
    Last edited: Sep 3, 2019
  8. pamamolf

    pamamolf Premium Member Premium Member

    3,446
    329
    83
    May 31, 2014
    Ratings:
    +627
    Local Time:
    3:50 PM
    Nginx-1.17.x
    MariaDB 10.3.x
    On your screenshot you are using https or is it as an example only?

    Or do you mean that you are not using it on the server?
     
  9. rdan

    rdan Well-Known Member

    4,605
    1,111
    113
    May 25, 2014
    Ratings:
    +1,632
    Local Time:
    8:50 PM
    Mainline
    10.2
    I mean I do not create/include HTTP to HTTPS redirect on Page Rule.
    As it's already taken care of by browser HSTS Preload List (local redirect 1ms).
     
    • Informative Informative x 1