Support » Plugin: Varnish/Nginx Proxy Caching » TTL override not working on JSON feed

  • I have “Cache TTL” set to 130
    I have “Override default TTL” ON
    Then on a JSON Feed page I have Varnish caching TTL set to 10
    But below are the headers from the server gotten with curl -I directly from apache and the page gets cached for 130 seconds via varnish…

    HTTP/1.1 200 OK
    Date: Tue, 19 Nov 2019 21:23:29 GMT
    Server: Apache
    X-Powered-By: PHP/7.3.9
    X-VC-Enabled: true
    X-VC-TTL: 130
    Link: <https://mysite/wp-json/&gt;; rel=”https://api.w.org/&#8221;
    Link: <https://mysite/?p=7112&gt;; rel=shortlink
    Vary: Accept-Encoding,User-Agent
    Content-Type: text/html; charset=UTF-8

    I thought it should override the default 130 and set X-VC-TTL: 10, is it because it’s a JSON feed ? I’ll add a custom rule but it would be nice if the Override worked as intended for this…

Viewing 1 replies (of 1 total)
  • Looking at the function : override_ttl()
    Maybe we need to include is_page_template() ?

    Current code:

    if ($postId && (is_page() || is_single())) {
      $ttl = get_post_meta($postId, $this->prefix . 'ttl', true);
      if (trim($ttl) != '') {
       Header('X-VC-TTL: ' . intval($ttl), true);
     }
    }

    Suggestion:

    if ($postId && (is_page() || is_single()) || is_page_template()) {
      $ttl = get_post_meta($postId, $this->prefix . 'ttl', true);
      if (trim($ttl) != '') {
       Header('X-VC-TTL: ' . intval($ttl), true);
     }
    }
    • This reply was modified 2 weeks, 2 days ago by shaundma.
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.