• Resolved DickRaney

    (@dickraney)


    Is it possible to disable the cache for all content except home page and some specifically designated pages?

    I see how to disable for pages or posts, etc. And I see how to Always Cache Filenames. But, don’t see a way to always cache specific pages.

    This is for a real estate website that has an IDX feed to display home for sale listings. I immediately get a warning when I activate WP Super Cache saying it is not compatible with the feed plugin. But I think it would be safe to cache pages that don’t show dynamic content. And most importantly I want to cache the home page, since that is where most people start.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Nauris

    (@pyronaur)

    Hi @dickraney!

    I’d suggest you re-think the approach here slightly. Caching is great to have wherever possible, which is the assumption caching plugins are built with. So you want every page on your site to be as fast as possible.

    With that in mind – if certain areas in your site are dynamic and need to be excluded from the cache, you can exclude them using the “Rejected URL Strings” field.

    I’m not sure what your IDX feed page structure is like, but let’s say it looks something like this:

    
    https://site.com/idx/product1
    https://site.com/idx/product1
    https://site.com/idx/product1
    

    You can use the “Rejected URL Strings” to reject the URL like so:

    
    /idx/*
    

    That’s going to exclude all URLs that match /idx/ from the cache.

    Does that solve the issue?

    Thread Starter DickRaney

    (@dickraney)

    Yes, I understand that, but in my case it would just be much simpler to exclude everything and then make exceptions for the ones that I want to allow. Unfortunately, it’s not as simple as the example you gave with all links proceeded with idx.

    Plugin Contributor Nauris

    (@pyronaur)

    What do the links look like? Maybe there’s another pattern you could specify.

    Alternatively, you can set a DONOTCACHEPAGE constant to true on the pages you want to be skipped from the cache, so if you really want to only cache the home page, you can do it like this:

    
    if( !is_home() && !is_front_page() && ! defined('DONOTCACHEPAGE') ) {
      define('DONOTCACHEPAGE', true);
    }
    
    Thread Starter DickRaney

    (@dickraney)

    That snippet will help. If I do that, how do I designate a page (other than home page) that I do want to cache?

    It looks like that snippet force DONOTCACHE (not cached) on everything except homepage/front_page that isn’t specifically defined as DONOTCACHEPAGE. So, a page /EXAMPLE would not be cached unless I define it as DONOTCACHEPAGE. In other words. defining as DONOTCACHEPAGE actually makes it get cached. Or am I misunderstanding the PHP logic ! defined('DONOTCACHEPAGE')?

    Plugin Contributor Nauris

    (@pyronaur)

    In PHP, you can only define constants once, so this additional check makes sure you don’t get warnings if for some reason the DONOTCACHEPAGE constant is already defined.

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

The topic ‘Cache home page only’ is closed to new replies.