is there a way to force a site visitor to clear cache for your website?

Hi, We have recently made some changes to the site, and seems only after clearing cache the changes appear. (as its a live site and has some active members on it) is there a way to force them to clear cache without asking them to do this directly? e.g. on the next time they load the website it will clear cache for them (and ideally have a switch or way to remove this so that eventually we can use some caching plugins to keep the site content static?)

Thanks

Tom

  • Adam Czajczyk

    Hey Tom,

    I hope you're having a nice day!

    If you're referring to the WP cache (in form of a plugin such as for example W3 Total Cache) then usually there's no way to set it like this - you'd want to simply disable caching, meaning that you'd not need caching plugin at all.

    As for browser caching. There's no any legitimate way to force "full cache removal" on user's site. However, there are some ways to overcome it:

    Adding this lines to your theme's header.php file inside <header></header> section should help:

    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />

    Most browsers do understand these meta tags and should follow these directives. Please note though that changing your theme's files is not recommended. Instead you may want to use a child theme of your current theme for this. Here's a handy guide on creating and using child themes:

    https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

    I hope that helps!

    Cheers,
    Adam

  • Adam Czajczyk

    Hey Tom,

    I hope you're having a nice day!

    If you're referring to the WP cache (in form of a plugin such as for example W3 Total Cache) then usually there's no way to set it like this - you'd want to simply disable caching, meaning that you'd not need caching plugin at all.

    As for browser caching. There's no any legitimate way to force "full cache removal" on user's site. However, there are some ways to overcome it:

    Adding this lines to your theme's header.php file inside <header></header> section should help:

    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />

    Most browsers do understand these meta tags and should follow these directives. Please note though that changing your theme's files is not recommended. Instead you may want to use a child theme of your current theme for this. Here's a handy guide on creating and using child themes:

    https://premium.wpmudev.org/blog/how-to-create-wordpress-child-theme/

    I hope that helps!

    Cheers,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.