• Resolved raven747

    (@raven747)


    I was working on setting up NGINX rules for the plugin

    These are what I came up with, although people may have better versions:

    In server:

    set $eo_base /wp-content/cache/easyopt/$host$uri;
    set $eo_br_file "";
    set $eo_gz_file "";
    set $eo_ok 1;

    if ($request_method != GET) { set $eo_ok 0; }
    if ($args != "") { set $eo_ok 0; }
    if ($eo_skip) { set $eo_ok 0; }
    if ($request_uri ~* "(/wp-admin|/wp-login|/wp-json|/feed/|/cart|/checkout|/my-account|/wc-api|.xml$|.txt$)") { set $eo_ok 0; }

    if ($eo_ok) { set $eo_gz_file "${eo_base}/index${eo_mobile}.html_gzip"; }
    if ($eo_ok) { set $eo_br_file "${eo_base}/index${eo_mobile}.html_br"; }
    if ($eo_br = 0) { set $eo_br_file ""; }

    location / {
    if (-f "$document_root$eo_br_file") { rewrite ^ $eo_br_file last; }
    if (-f "$document_root$eo_gz_file") { rewrite ^ $eo_gz_file last; }
    try_files $uri $uri/ /index.php?$args;
    }

    location /wp-content/cache/easyopt/ { internal; }

    location ~ /wp-content/cache/easyopt/..html_br$ { internal; add_header Content-Type "text/html; charset=UTF-8"; add_header Content-Encoding br; add_header Vary Accept-Encoding; add_header X-Easy-Optimizer-Cache "HIT-nginx"; add_header Cache-Control "no-cache, must-revalidate"; add_header CDN-Cache-Control "max-age=2592000, stale-while-revalidate=86400, stale-if-error=86400"; } location ~ /wp-content/cache/easyopt/..html_gzip$ {
    internal;
    add_header Content-Type "text/html; charset=UTF-8";
    add_header Content-Encoding gzip;
    add_header Vary Accept-Encoding;
    add_header X-Easy-Optimizer-Cache "HIT-nginx";
    add_header Cache-Control "no-cache, must-revalidate";
    add_header CDN-Cache-Control "max-age=2592000, stale-while-revalidate=86400, stale-if-error=86400";
    }

    in http

    map $http_cookie $eo_skip {
    default 0;
    "~*(easyopt_skip_cache|wordpress_logged_in_|wordpress_sec_|comment_author_|wp-postpass_|woocommerce_items_in_cart|wp_woocommerce_session_|edd_items_in_cart)" 1;
    }
    # Only needed if "Separate mobile cache" is ON. Omit it and phones get desktop pages.
    map $http_user_agent $eo_mobile {
    default "";
    "~*(android.+mobile|blackberry|iemobile|ip(hone|od)|kindle|maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino)" "-mobile";
    }
    map $http_accept_encoding $eo_br { default 0; "~*(^|,)\s*br\s*(,|$)" 1; }

    If this can be helpful to some people, all the better. Loving the plugin, and want to see it do well!

    • This topic was modified 2 weeks ago by raven747.
Viewing 1 replies (of 1 total)
  • Plugin Contributor Uzair

    (@uzairwp)

    we already have nginx rules in caching > Advanced: optional Nginx server rules

    please test it and let us know if any issue.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.