• Resolved corytrevor

    (@corytrevor)


    Hi

    I’ve been testing out the File-Based caching a lot recently and I noticed that I’d never get any SG-F-Cache: MISS’ response headers, it would be either be nothing if it was a cache miss or ‘SG-F-Cache: HIT’ for a hit.

    If I comment out the ‘$should_send_miss = false;’ line of this part that starts on line 134 of sg-cachepress/core/File_Cacher/Cache.php then it works how I’d expect it to and returns ‘SG-F-Cache: MISS’ for a file-cache miss.

    if (
    	( @file_exists( '/etc/yum.repos.d/baseos.repo' ) && @file_exists( '/Z' ) ) &&
    	empty( $_COOKIE[ 'wordpress_logged_in_' . "COOKIEHASH" ] )
    	) {
    		// $should_send_miss = false;
    }

    I’m hosted on SiteGround so I’m wondering is that section code designed to detect the SG hosting environment and if so why would it be set up to not return any ‘SG-F-Cache: MISS’ headers for SG hosted sites?

    Thanks

    • This topic was modified 2 years ago by corytrevor.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Plamen M

    (@plamenm)

    Hello @corytrevor ,

    Could you please elaborate a bit more so that we can try to assist you better – what is the exact real-use problem that you are trying to tackle here? Why do you need this header to be a MISS?

    We look forward to your reply.

    Regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

    Thread Starter corytrevor

    (@corytrevor)

    Hi @plamenm

    The use case for the MISS header is that when I check on a site or page to see if the file-based caching is working, it tells me that the file-based caching is successfully enabled but that the HTML file for that page either doesn’t exist in the cache or has expired. Without that MISS header it’s impossible to know what the status of the file-based cache is, only that it wasn’t a HIT.

    This is why the plugin has been coded to return the MISS header in Cache.php:

    if ( ! file_exists( $cache_file ) ) {
    	if ( $should_send_miss ) {
    		header( 'SG-F-Cache: MISS' );
    	}
    	return;
    }

    But for some reason it has also been coded to not send the MISS header if ‘/etc/yum.repos.d/baseos.repo’ is present and I’m curious as to why that is as that is the part of the code that prevents the MISS header from being sent on my SG hosted sites.

    Cheers

    Plugin Support Plamen M

    (@plamenm)

    Thank you for the update. This all depends on which level of caching is providing the cache. We have several levels:

    – SiteGround CDN Cache
    – SiteGround Dynamic Caching
    – SiteGround File Based (Static) Caching

    The static caching is enabled by default on our servers. However, if you have the other levels enabled, they would serve the static elements before the File Based caching – hence the header results that you see. If you would disable all levels of caching – including the File Based Caching, then flush the cache, including the cache in your browser, then you would get a non-cached result for your site
    elements.

    If you need any further assistance, best, post a support ticket through the Helpdesk section in your User Area and we will check the exact use case that you are reporting.

    Regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

    Thread Starter corytrevor

    (@corytrevor)

    Yes, and each caching has level has different response headers i.e sg-f-cache for the file-based cache and x-proxy-cache for the dynamic cache.

    Here is how to replicate the missing ‘sg-f-cache: MISS’ header issue. On an SG hosted site, enable file-based caching and leave the ‘Preheat cache’ option unchecked. Then Purge SG Cache.

    Visit the site in an incognito window with the network tab open in dev tools. Inspect the response headers and note that there’s an ‘x-proxy-cache: MISS’ header but there’s no ‘sg-f-cache: MISS’ header which you would expect there to be as the cached as the cache has just been purged.

    Open sg-cachepress/core/File_Cacher/Cache.php and comment out line 138:
    // $should_send_miss = false;

    Repeat the previous steps and note that this time it correctly returns the ‘sg-f-cache: MISS’ header for a cache miss as you would expect it to do.

    Thanks

    Plugin Support Gergana Petrova

    (@gpetrova)

    Hello @corytrevor,

    We have brought this to the attention of the plugin’s developers and they will be investigating this further on their end.

    A fix for this will be deployed in one of the future versions of the plugin. You may follow the Changelog for additional information.

    Best Regards,
    Gergana Petrova

    Thread Starter corytrevor

    (@corytrevor)

    That’s great, thanks @gpetrova

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Never get an ‘SG-F-Cache: MISS’ response header’ is closed to new replies.