admin管理员组

文章数量:1295303

I use Wordpress plugin: snippets to show some data in database. Everything is OK, however, when I change the content in the database. After that I refresh many time in the page. And the content is not change. I close the web page, and wait for 5 minutes. Reopen the page again, the content is updated. What happens in my situation? Please give me some suggestion!

In Snippets:

public function some_function() {
    global $wpdb;
    $results = $wpdb->get_var( 
        $wpdb->prepare("SELECT count(ID) as total FROM {$wpdb->prefix}sample_table") 
        );
    return $results;
}
add_shortcode('sample_shortcode', 'some_function');

In the Page - I add the shortcode

[sample_shortcode]

I use Wordpress plugin: snippets to show some data in database. Everything is OK, however, when I change the content in the database. After that I refresh many time in the page. And the content is not change. I close the web page, and wait for 5 minutes. Reopen the page again, the content is updated. What happens in my situation? Please give me some suggestion!

In Snippets:

public function some_function() {
    global $wpdb;
    $results = $wpdb->get_var( 
        $wpdb->prepare("SELECT count(ID) as total FROM {$wpdb->prefix}sample_table") 
        );
    return $results;
}
add_shortcode('sample_shortcode', 'some_function');

In the Page - I add the shortcode

[sample_shortcode]
Share Improve this question edited Apr 15, 2021 at 9:50 Rup 4,4004 gold badges29 silver badges29 bronze badges asked Apr 15, 2021 at 9:00 ho quoc dungho quoc dung 1 1
  • 1 This is probably caching then, either in the code snippet plugin (if it does that) or on your web server or on your CDN if you have one or on your browser (because of server caching configuration) – Rup Commented Apr 15, 2021 at 9:51
Add a comment  | 

1 Answer 1

Reset to default 1

Shortcodes don't need to be refreshed, they aren't cached.

Instead it sounds like you have either CDN, page, browser, or database caching. Check for caching plugins that need clearing, and flush any CDN caches you might have.

本文标签: How to reload the shortcode content when the database is changing