Welcome to Centmin Mod Community
Become a Member

Nginx Cookieless domain for better performance

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by pamamolf, May 31, 2015.

  1. pamamolf

    pamamolf Premium Member Premium Member

    4,069
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    1:58 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Hi


    I was read on Gtmetrix and Yslow that i can enable a cookieless domain to improve performance and get a higher score there....

    Reading on the net one way is to create a subdomain and serve from there the static cookies and some other articles recommend some settings in Nginx for this without the subdomain and some of them even use something like this:

    Code:
    fastcgi_hide_header Set-Cookie;
    Any ideas what is the best way to improve this?

    Thanks
     
  2. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
    I'm using this kind of Implementation on my XenForo Forum and WP site.
    Here's the config I used:
    Code:
    server {
        listen 80;
        server_name x.phc.onl;
    
        include /usr/local/nginx/conf/pagespeed.conf;
        include /usr/local/nginx/conf/pagespeedhandler.conf;
        include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
        log_not_found off;
        error_log off;
        fastcgi_hide_header Set-Cookie;
        root /home/nginx/domains/staticfiles/public;
    
        location / {
        if ($request_filename ~ "\.(css|js|jpg|jpeg|gif|ico|png|bmp|pict|csv|doc|pdf|pls|ppt|tif|tiff|eps|ejs|swf|midi|mid|ttf|eot|woff|otf|svg|svgz|webp|docx|xlsx|xls|pptx|ps|class|jar|woff2|less|scss)$") {
            add_header Pragma "public";
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
            add_header Access-Control-Allow-Origin *;
            access_log off;
            expires 1M;
    
            break;
            }
        return 302 http://phc.onl$request_uri;
        }
    }
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I honestly don't bother with cookieless domains anymore as they have to be done from a domain not the same as your main site domain. As such there's ever the chance that folks with ad blockers only whitelisted your main domain. So any cookieless domains could be blocked. This means css and js is not being served and just breaks your site completely. Not a good first impression for new visitors to your site !
     
  4. pamamolf

    pamamolf Premium Member Premium Member

    4,069
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    1:58 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    I am just looking for Centminmod level optimizations to get higher score on Gtmetrix/Yslow :)
     
  5. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    scores are nice, but reality and real life more important :)
     
  6. pamamolf

    pamamolf Premium Member Premium Member

    4,069
    427
    83
    May 31, 2014
    Ratings:
    +832
    Local Time:
    1:58 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Yes sure no problem :)
     
  7. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
    Adblocker extension doesn't block static files/content.
    Only known adds.
     
  8. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    some other browser extensions can - had it happen in the past on a few of my sites :)
     
  9. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
    BTW, With HTTP/2, CDN and static domain practice is obsolete :)
     
  10. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    same with SPDY/3.1 :)
     
  11. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
    Can please name what adblocker extension specifically they are using?
     
  12. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Can't remember this was a few years ago but the forum members reported the issue and i don't them to whitelist the cdn/cookieless domains and it fixed the problem.
     
  13. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
  14. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  15. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
    Now, my forum is back to pure HTTPS.
    Waiting for HTTP/2 very soon I hope :)
    Roadmap – nginx
     
  16. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
  17. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Nice... SSL is here to stay ! FYI, I now 2 source suppliers for my SSL certificates I offer to Centmin Mod Premium Members so some prices had to be revised up while others were revised down i.e. Comodo Positive Multi-domain is much cheaper :)
     
  18. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
    Right now, back to using Cloudflare FULL with HTTPS.
    Until HTTP/2 comes out :).
     
  19. rdan

    rdan Well-Known Member

    5,439
    1,398
    113
    May 25, 2014
    Ratings:
    +2,187
    Local Time:
    6:58 AM
    Mainline
    10.2
    Planning of using HTTPS fully but looking at my GA stats for this month:
    upload_2015-6-29_3-47-20.png

    I think, still not good to use HTTTPS :(
     
  20. eva2000

    eva2000 Administrator Staff Member

    53,530
    12,134
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,677
    Local Time:
    8:58 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    add the average time on page metric to the stats and see, some times xp ones are bots too so average time of page is like <0.05 seconds or something

    but yeah some Asian countries are still predominantly WinXP and older