Want to subscribe to topics you're interested in?
Become a Member

Wordpress expires not set on Autoptimize js/css requests

Discussion in 'Blogs & CMS usage' started by ct_roy, Nov 16, 2020.

  1. ct_roy

    ct_roy Premium Member Premium Member

    26
    6
    3
    Jun 21, 2020
    Ratings:
    +10
    Local Time:
    2:52 PM
    1.17.10
    10.3.22
    Running some webperf tests I noticed that AO assets don't have expires set.
    I spotted the thread announcing the new AO-Fallback header from September, but I've deactivated the AO fallback in AO itself.

    I'm wondering do I need to do something else to ensure there are expires set on those assets? (also, I've double checked, the css/js files do indeed exist and AO is definitely off).
     
  2. ct_roy

    ct_roy Premium Member Premium Member

    26
    6
    3
    Jun 21, 2020
    Ratings:
    +10
    Local Time:
    2:52 PM
    1.17.10
    10.3.22
    adding expires30d to this block seems to do the trick

    Code:
    location ~* /wp-content/cache/autoptimize/.*\.(js|css)$ {
      include /usr/local/nginx/conf/php.conf;
      add_header AO-Fallback 1;
      try_files $uri $uri/ /wp-content/autoptimize_404_handler.php;
      expires 30d;
    }
     
  3. eva2000

    eva2000 Administrator Staff Member

    45,728
    10,382
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,112
    Local Time:
    12:52 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    Interesting I see expires header for autoptimize plugin on my test installs. But yes adding expires there would ensure it is set.

    What is output for the following domains replacing domain assigned variable with your Wordpress domain name
    Code (Text):
    domain=yourdomain.com
    wp option list --search=autoptimize_* --allow-root --path=/home/nginx/domains/$domain/public
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    45,728
    10,382
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,112
    Local Time:
    12:52 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
  5. ct_roy

    ct_roy Premium Member Premium Member

    26
    6
    3
    Jun 21, 2020
    Ratings:
    +10
    Local Time:
    2:52 PM
    1.17.10
    10.3.22
    Here's my AO settings output
    Code:
    +---------------------------------+-------------------------------------------------------------------------------------------+
    | option_name                     | option_value                                                                              |
    +---------------------------------+-------------------------------------------------------------------------------------------+
    | autoptimize_cache_clean         | 0                                                                                         |
    | autoptimize_cache_fallback      |                                                                                           |
    | autoptimize_cache_nogzip        | on                                                                                        |
    | autoptimize_ccss_version        | AO_2.7.8                                                                                  |
    | autoptimize_cdn_url             |                                                                                           |
    | autoptimize_css                 | on                                                                                        |
    | autoptimize_css_aggregate       | on                                                                                        |
    | autoptimize_css_datauris        |                                                                                           |
    | autoptimize_css_defer           |                                                                                           |
    | autoptimize_css_defer_inline    |                                                                                           |
    | autoptimize_css_exclude         | wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css              |
    | autoptimize_css_include_inline  |                                                                                           |
    | autoptimize_css_inline          |                                                                                           |
    | autoptimize_css_justhead        |                                                                                           |
    | autoptimize_enable_site_config  | on                                                                                        |
    | autoptimize_extra_settings      | a:5:{s:31:"autoptimize_extra_radio_field_4";s:1:"1";s:32:"autoptimize_extra_select_field_ |
    |                                 | 6";s:1:"2";s:34:"autoptimize_extra_checkbox_field_1";s:1:"1";s:30:"autoptimize_extra_text |
    |                                 | _field_2";s:239:"https://i0.wp.com, https://ii1.wp.com, https://ii2.wp.com, https://is0.w |
    |                                 | p.com, https://istats.wp.com, https://ifonts.googleapis.com, https://ipixel.wp.com, https |
    |                                 | ://ifonts.gstatic.com, https://fonts.googleapis.com, https://fonts.gstatic.com";s:30:"aut |
    |                                 | optimize_extra_text_field_3";s:0:"";}                                                     |
    | autoptimize_html                | on                                                                                        |
    | autoptimize_html_keepcomments   |                                                                                           |
    | autoptimize_imgopt_launched     | on                                                                                        |
    | autoptimize_imgopt_settings     | a:5:{s:35:"autoptimize_imgopt_checkbox_field_1";s:1:"0";s:33:"autoptimize_imgopt_select_f |
    |                                 | ield_2";s:1:"2";s:35:"autoptimize_imgopt_checkbox_field_3";s:1:"0";s:35:"autoptimize_imgo |
    |                                 | pt_checkbox_field_4";s:1:"0";s:31:"autoptimize_imgopt_text_field_5";s:0:"";}              |
    | autoptimize_js                  | on                                                                                        |
    | autoptimize_js_aggregate        | on                                                                                        |
    | autoptimize_js_exclude          | seal.js, js/jquery/jquery.js, kirki/modules/webfont-loader/vendor-typekit/webfontloader.j |
    |                                 | s                                                                                         |
    | autoptimize_js_forcehead        |                                                                                           |
    | autoptimize_js_include_inline   |                                                                                           |
    | autoptimize_js_justhead         |                                                                                           |
    | autoptimize_js_trycatch         |                                                                                           |
    | autoptimize_minify_excluded     | on                                                                                        |
    | autoptimize_optimize_checkout   | on                                                                                        |
    | autoptimize_optimize_logged     | on                                                                                        |
    | autoptimize_service_availablity | a:2:{s:12:"extra_imgopt";a:3:{s:6:"status";s:2:"up";s:5:"hosts";a:1:{i:1;s:26:"https://cd |
    |                                 | n.shortpixel.ai/";}s:16:"launch-threshold";s:4:"4096";}s:7:"critcss";a:2:{s:6:"status";s: |
    |                                 | 2:"up";s:5:"hosts";a:1:{i:1;s:24:"https://criticalcss.com/";}}}                           |
    | autoptimize_show_adv            | 1                                                                                         |
    | autoptimize_version             | 2.7.8                                                                                     |
    +---------------------------------+-------------------------------------------------------------------------------------------+
    Awesome thanks!
     
  6. eva2000

    eva2000 Administrator Staff Member

    45,728
    10,382
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,112
    Local Time:
    12:52 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    settings look about right. On my test instance

    Code (Text):
    wp option list --search=autoptimize_* --allow-root --path=/home/nginx/domains/$domain/public
    +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | option_name                     | option_value                                                                                                                                                                                                         |
    +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | autoptimize_cache_clean         | 0                                                                                                                                                                                                                    |
    | autoptimize_cache_fallback      | on                                                                                                                                                                                                                   |
    | autoptimize_cache_nogzip        | on                                                                                                                                                                                                                   |
    | autoptimize_ccss_version        | AO_2.7.8                                                                                                                                                                                                             |
    | autoptimize_cdn_url             |                                                                                                                                                                                                                      |
    | autoptimize_css                 | on                                                                                                                                                                                                                   |
    | autoptimize_css_aggregate       | on                                                                                                                                                                                                                   |
    | autoptimize_css_datauris        |                                                                                                                                                                                                                      |
    | autoptimize_css_defer           |                                                                                                                                                                                                                      |
    | autoptimize_css_defer_inline    |                                                                                                                                                                                                                      |
    | autoptimize_css_exclude         | wp-content/cache/, wp-content/uploads/, admin-bar.min.css, dashicons.min.css                                                                                                                                         |
    | autoptimize_css_include_inline  | on                                                                                                                                                                                                                   |
    | autoptimize_css_inline          |                                                                                                                                                                                                                      |
    | autoptimize_css_justhead        |                                                                                                                                                                                                                      |
    | autoptimize_enable_site_config  | on                                                                                                                                                                                                                   |
    | autoptimize_html                |                                                                                                                                                                                                                      |
    | autoptimize_html_keepcomments   |                                                                                                                                                                                                                      |
    | autoptimize_imgopt_launched     | on                                                                                                                                                                                                                   |
    | autoptimize_js                  | on                                                                                                                                                                                                                   |
    | autoptimize_js_aggregate        | on                                                                                                                                                                                                                   |
    | autoptimize_js_exclude          | wp-includes/js/dist/, wp-includes/js/tinymce/, js/jquery/jquery.js                                                                                                                                                   |
    | autoptimize_js_forcehead        |                                                                                                                                                                                                                      |
    | autoptimize_js_include_inline   |                                                                                                                                                                                                                      |
    | autoptimize_js_justhead         |                                                                                                                                                                                                                      |
    | autoptimize_js_trycatch         |                                                                                                                                                                                                                      |
    | autoptimize_minify_excluded     | on                                                                                                                                                                                                                   |
    | autoptimize_optimize_checkout   |                                                                                                                                                                                                                      |
    | autoptimize_optimize_logged     |                                                                                                                                                                                                                      |
    | autoptimize_service_availablity | a:2:{s:12:"extra_imgopt";a:3:{s:6:"status";s:2:"up";s:5:"hosts";a:1:{i:1;s:26:"https://cdn.shortpixel.ai/";}s:16:"launch-threshold";s:4:"4096";}s:7:"critcss";a:2:{s:6:"status";s:2:"up";s:5:"hosts";a:1:{i:1;s:24:" |
    |                                 | https://criticalcss.com/";}}}                                                                                                                                                                                        |
    | autoptimize_version             | 2.7.8                                                                                                                                                                                                                |
    +---------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+