Support » Plugin: W3 Total Cache » How to leverage browser caching for .woff files

  • Hi is it possible to leverage browser caching for .woff font files with this plugin?

    I’m trying to resolve the following error in Page Speed:

    Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
    Leverage browser caching for the following cacheable resources:
    https://herniameshlawsuit.org/…/fonts/fontawesome-webfont.woff2?v=4.7.0 (4 hours)

    Can this all be fixed via edits in my nginix.conf file? If so, what do I need to add exactly?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • My current Nginix.conf looks like this:

    # BEGIN W3TC Page Cache cache
    location ~ /wp-content/cache/page_enhanced.*html$ {
    }
    location ~ /wp-content/cache/page_enhanced.*gzip$ {
        gzip off;
        types {}
        default_type text/html;
        add_header Content-Encoding gzip;
    }
    # END W3TC Page Cache cache
    # BEGIN W3TC Browser Cache
    gzip on;
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint application/x-shockwave-flash image/tiff application/x-font-ttf audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel;
    # END W3TC Browser Cache
    # BEGIN W3TC Page Cache core
    set $w3tc_rewrite 1;
    if ($request_method = POST) {
        set $w3tc_rewrite 0;
    }
    if ($query_string != "") {
        set $w3tc_rewrite 0;
    }
    if ($request_uri !~ \/$) {
        set $w3tc_rewrite 0;
    }
    if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle)") {
        set $w3tc_rewrite 0;
    }
    set $w3tc_preview "";
    if ($http_cookie ~* "(w3tc_preview)") {
        set $w3tc_preview _preview;
    }
    set $w3tc_enc "";
    if ($http_accept_encoding ~ gzip) {
        set $w3tc_enc _gzip;
    }
    if (!-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_preview.html$w3tc_enc") {
      set $w3tc_rewrite 0;
    }
    if ($w3tc_rewrite = 1) {
        rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_preview.html$w3tc_enc" last;
    }
    # END W3TC Page Cache core
    

    It’salready on your nginx.conf.

    This part:
    gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint application/x-shockwave-flash image/tiff application/x-font-ttf audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel;

    woff is there, it’s gzipped

    (4 hours)

    I think the problem is not your woff2 not cached, but the cache expiry seems too short, try to change it to a month.

    Trying to understand why i still have the error.

    I have the following settings globally activated in W3TC >browser cache

    expires header
    cache control header
    entity tag (ETag)
    W3 Total Cache header
    Enable HTTP (gzip) compression

    What could i be doing wrong?

    Where did you check the site? I checked your site on GTmetric and Google page speed insight, this specific part is fine.

    Google. I still the error for:

    https://herniameshlawsuit.org/wp-content/themes/panoramic/library/fonts/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0

    Not sure how to adress it. It still asks me to set an expiry date or a maximum age in the HTTP headers for static resources. It references the URL above

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to leverage browser caching for .woff files’ is closed to new replies.