• Resolved luismt74

    (@luismt74)


    Hello, I have some doubts with the configuration. Can you help me please?

    Database Cache should be used only if Object Cache is not possible? I shouldn’t enable both options right?
    How do I know if my site uses the Object Cache API?

    I use CloudFlare, do I need to install the extension? Minify is enabled in W3.

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

    (@vmarko)

    Hello @luismt74

    Thank you for your inquiry and I am happy to answer.
    WordPress website utilizes database quite a lot. And database caching allows us to decrease database usage. Database caching allows to cache database request results.

    Database caching can make your site faster if the time needed to get data from the database is more than the time needed to get data from the cache.

    So, if you are on shared hosting, then RAM-based caching is likely to be unavailable for you. And disk-based caching is not that efficient. In other words, if you are on shared hosting, it’s recommended not to use database caching.

    Object Cache allows us to get data from the database more efficiently. Its purpose is similar to what Database Cache does. But compared to Database Cache, Object cache is more efficient as it allows us to process fewer requests.

    As a rule of thumb, Object Cache is not worth using on shared hosting for the same reason as Database Cache, i.e. database is often not the performance bottleneck, but disk input-output operations.

    So in other words, if on shared hosting, enabling those two caching options may slow down your website. If however you wish to use them, it’s recommended to use only Object Caching because, as explained above, object Cache allows to get data from the database more efficiently. Its purpose is similar to what Database Cache does. But compared to Database Cache, Object cache is more efficient as it allows to process fewer requests.

    As for the Cloudflare, you need to enable the extension in Performance>extensions and authorize Cloudflare.
    Please check this article for detailed instructions.

    Thank you!

    Thread Starter luismt74

    (@luismt74)

    Very thanks Marko. Sorry, I should have said that have a dedicated server with memcached. This is the correct setting right?

    View post on imgur.com

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @luismt74

    Thank you for the information.
    Yes that is great. And using memory-based caching for Object caching is also a great solution.
    Thank you!

    Thread Starter luismt74

    (@luismt74)

    Thanks Marko, one last question please:

    If I enable the option: “Page Cache -> Cache front page” my theme stops updating the number of visits to the posts. Is it possible to exclude this?
    I’m not sure, but I think the function is “post_views_count”.

    • This reply was modified 4 years, 9 months ago by luismt74.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @luismt74

    You can use Page Fragment cache for this.
    Please check this article on How To Implement Page Fragment Caching Exception In W3 Total Cache.
    Thanks!

    Thread Starter luismt74

    (@luismt74)

    Thanks marko, I’m not sure if I’m doing it right:

    my functions.php says this:
    require get_template_directory() . '/inc/ajax-post-views.php';

    and the content of ajax-post-views.php is:

    <?php
    function wpst_set_post_views() {
        $nonce = $_POST['nonce'];
        if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) )
          die ( 'Busted!');
    
        if( ! isset($_POST['post_id'] ) ){
          die ( 'post id required!');
        }
    
        $postID = $_POST['post_id'];
    
        $count_key = 'post_views_count';
        $count = get_post_meta($postID, $count_key, true);
        if($count == ''){
          $count = 0;
          delete_post_meta($postID, $count_key);
          add_post_meta($postID, $count_key, '0');
        }else{
          $count++;
          update_post_meta($postID, $count_key, $count);
        }
    
        wp_send_json(array('views' => $count));
        wp_die();
    }
    add_action('wp_ajax_nopriv_post-views', 'wpst_set_post_views');
    add_action('wp_ajax_post-views', 'wpst_set_post_views');

    So should I add it like this to wp-config.php?

    define(‘W3TC_DYNAMIC_SECURITY’, ‘mycode’);
    <!-- mfunc mycode -->
    function wpst_set_post_views();
    <!-- /mfunc mycode -->
    Thread Starter luismt74

    (@luismt74)

    Please Marko, can you confirm if this is correct? Thanks

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @luismt74

    Are you using any plugins for this?

    Thread Starter luismt74

    (@luismt74)

    Hello Marko, Thanks for answering. No, it is a function that owns the theme.

    Thread Starter luismt74

    (@luismt74)

    Thread Starter luismt74

    (@luismt74)

    Please Marko, can you confirm if this is correct?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @luismt74

    The best thing is to reach out to the support of the theme you are using (I’ve never tested this theme) and check which part of the php needs to be wrapped with mfunc to exclude it from caching.
    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Some doubts with the configuration’ is closed to new replies.