Support » Plugin: W3 Total Cache » Caching 304 in IF_MODIFIED_SINCE with Clearfy

  • Resolved hardbuz

    (@hardbuz)


    Hello!

    I use the Clearfy plugin – through it I display the Last Modified and If-Modified-Since headers. For caching – W3TC. Server – nginx. There is a problem with unnecessarily caching a 304 response.

    Problem:
    1. Activating the if-modified-since header in Clearfy
    2. Clearing cache in W3TC.
    3. Requesting the page using the if-modified-since header – we get a 304 response and a blank page – CORRECT.
    4. BUT the page adds to cache. The second time we request the page with the usual GET – we get a blank page and a 304 response.

    Can u help me? Is it possible to avoid caching this response? Goal – Correct cache and correct response for “IF_MODIFIED_SINCE” request. Thank you.

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

    (@vmarko)

    Hello @hardbuz
    Thank you for your inquiry and I am happy to assist you with this.

    3. Requesting the page using the if-modified-since header – we get a 304 response and a blank page – CORRECT.
    4. BUT the page adds to the cache. The second time we request the page with the usual GET – we get a blank page and a 304 response.

    Can you please clarify this a bit? Are you getting the 304 or 200 responses for the page?
    Thanks!

    Thread Starter hardbuz

    (@hardbuz)

    Maybe:

    ORDINARY SCENARIO
    1. There is no cache.
    2. The first simple request to the page. The answer is 200.
    3. The cache is created.
    4. The second simple request to the page. The answer is 200.
    RIGHT

    UNUSUAL SCENARIO
    1. There is no cache.
    2. First request with “IF_MODIFIED_SINCE”. The answer is 304, a blank page. RIGHT.
    3. The cache is created.
    4. The second simple request to the page, without “IF_MODIFIED_SINCE”. The answer is 304, a blank page. WRONG (!!! Should be 200 with any data from original page).

    Hope it could clarify the situation)

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @hardbuz

    Thank you for the information.
    Can you please share your Performance>Browser Cache settings, specifically for HTML&XML?
    Thank you!

    Thread Starter hardbuz

    (@hardbuz)

    Sure. Original settings without my tests:

    https://imgur.com/a/GuaUXyl

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @hardbuz

    When Server returns Last-Modified: header with a timestamp, and you include If-Modified-Since: header in future requests. In case the file hasn’t changed since the given date, the server replies with an HTTP 304 Not Modified response.
    As you can see you’ve set the Last-Modified header to enable 304 Not Modified response.
    Thanks!

    Thread Starter hardbuz

    (@hardbuz)

    Hello, @vmarko

    Ok. Let’s make changes to our settings:

    1. Disable Last-Modified header in W3TC:

    https://imgur.com/a/Wog7jNG

    2. Clear the W3TC cache.

    3. Request the page at the first time with IF_MODIFIED_SINCE header (for example, simulate a search robot or browser request).

    4. Result – 304 with a blank page – CORRECT (only for request with IF_MODIFIED_SINCE).
    But this page is written to the W3TC cache – it gives it away even with requests without IF_MODIFIED_SINCE to a normal user. And this user sees a white screen (and search engines also see this screen):

    https://imgur.com/ToIi8GT

    My problem is that the W3TC caches this 304 response as a regular page and leaves it blank on further requests. And I don’t know what to do with this ( Thanks.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @hardbuz

    I am checking this. I’ll get back to you when I have more information.
    Thanks!

    Thread Starter hardbuz

    (@hardbuz)

    Ok. Thanks!

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @hardbuz

    I’ve spoken with the team od devs and tested this. The problem is with the cross plugin incompatibility. The mentioned plugin should define DONTPAGECACHE constant when the response shouldn’t be cached. This is basically caching of caching setup and W3 Total Cache is enough.
    Thank you!

    Thread Starter hardbuz

    (@hardbuz)

    Hello @vmarko

    Thanks! This is a great solution.
    Correct – DONOTCACHEPAGE

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    You are most welcome!

    We would really appreciate it if you could take a minute and post a review here. This will help us to continue offering a top-notch product to users.
    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Caching 304 in IF_MODIFIED_SINCE with Clearfy’ is closed to new replies.