• Resolved marolej

    (@marolej)


    Hi,

    I have installed W3 Total Cache plugin on WordPress 5.4 and enabled ‘Browser Cache’. In details of ‘Browser Cache’ configuration we enabled for CSS & JS with:
    * Set Last-Modified header: Enabled,
    * Set expires header: Enabled,
    * Expires header lifetime: 51 – (as for testing purpose),
    * Set cache control header: Enabled,
    * Cache Control policy: cache with max-age (“public, max-age=EXPIRES_SECONDS”)
    * Set entity tag (eTag): Enabled

    For first fresh request for minified CSS file we are getting below ‘Cache-Control’ response from WordPress:
    cache-control: max-age=51, public
    so, looks ok. But after expiration of 51 sec. the conditional request is performed, and in the response (304 in case no change) we are always getting then:
    cache-control: max-age=0, public
    so, browser cache is disabled infinitely.

    Is it possible to getting max-age=51 also for 304 response?

    Regards,
    Marcin

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @marolej

    Thank you for your inquiry and I am happy to assist you with this.
    Try setting the cache control to cache with validation ("public, must-revalidate, proxy-revalidate")
    Make sure to save all settings and purge the cache.
    Thanks!

    Thread Starter marolej

    (@marolej)

    Hi Marko,

    I checked your proposition, but the effect of this change is to perform a validation of the cached resources in the browser with the server every time the site is visited.

    I would like to omit such validation to speed-up a page by using browser cache without validation by some time (in my example by 51 sec). That’s why I would like o get Cache-Control: max-age=51 for 200 and also for 304 responses.

    Regards,

    Thread Starter marolej

    (@marolej)

    Hi Marko,

    I saw when I disabled Minify feature in ‘W3 Total Cache’ plugin I started getting Cache-Control:max-age=51. Looks like the issue is related to minification.

    Probably the issue is related with some code below in .htaccess:

    # BEGIN W3TC Minify cache
    FileETag MTime Size
    <IfModule mod_mime.c>
        AddType text/css .css_gzip
        AddEncoding gzip .css_gzip
        AddType application/x-javascript .js_gzip
        AddEncoding gzip .js_gzip
    </IfModule>
    <IfModule mod_deflate.c>
        <IfModule mod_setenvif.c>
            SetEnvIfNoCase Request_URI \.css_gzip$ no-gzip
            SetEnvIfNoCase Request_URI \.js_gzip$ no-gzip
        </IfModule>
    </IfModule>
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType text/css M51
        ExpiresByType application/x-javascript M51
    </IfModule>
    <IfModule mod_headers.c>
        Header set X-Powered-By "W3 Total Cache/0.14.2"
        Header set Vary "Accept-Encoding"
        Header set Pragma "public"
        Header append Cache-Control "public"
    </IfModule>
    # END W3TC Minify cache
    # BEGIN W3TC Minify core
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /wp-content/cache/minify/
        RewriteCond %{HTTP:Accept-Encoding} gzip
        RewriteRule .* - [E=APPEND_EXT:_gzip]
        RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -f
        RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]
        RewriteRule ^(.+\.(css|js))$ /index.php [L]
    </IfModule>
    # END W3TC Minify core

    Regards,

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @marolej

    Have you started getting Cache-Control:max-age=51 for both 200 and 304?
    n theory you shouldn’t have to send Cache-Control for a 304 — the recipient should just continue to use the cache directives that it received from the original 200
    Thanks!

    Thread Starter marolej

    (@marolej)

    Hi Marko,

    Yes, I started getting Cache-Control:max-age=51 for both 200 and 304. It was related to
    ExpiresByType text/css M51
    saw I changed it to:
    ExpiresByType text/css A51

    Btw, Is there any configuration in ‘W3 Total Cache’ to periodically clean up all minified CSS & JS files and regenerated them automatically (for example, once a week)?

    Regards,

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @marolej

    Thank you for your patience. I’ve spoken with the team and I can confirm it’s a bug.
    I’ve created a Github issue in our repository on your behalf.
    Please make sure to track the progress of the issue regularly.
    And to answer your other question, not there is no option to periodically clean up all minified CSS & JS files and regenerated them automatically.
    What you can do is to enable Prevent caching of objects after settings change option in Performance>Browser Cache>CSS&JS. This will add the query string to JS and CSS files and you can update that query string also in Performance>Browser Cache by clicking on the “Update media query string” button just above the General sub-box

    Thread Starter marolej

    (@marolej)

    Hi Marko,

    Ok, thanks for the update.

    Good day,
    Marcin

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Cache-Control disabled for 304 response’ is closed to new replies.