Sometimes caching can cause site visitors to see outdated or incorrect content. For such cases you can manually control or disable caching for your site pages.
You can manually control page caching by:
If the data on your site page changes very frequently, you can disable caching for that page, ensuring your site is always displaying the most up-to-date information. If the data on your page updates regularly, you can set your page's cache to clear and refresh at an interval that matches your needs.
To disable or manage caching:
In the editor, click the Pages icon on the left sidebar to open the Site Pages panel.
Click the More Actions icon for the page you want to control caching, and then select Settings. This opens the Page Settings panel for that page.
Click Advanced Settings and turn on the Manually control caching for this page toggle.
Open the How often do you want to reset this page's cache? dropdown.
If your page’s data only updates occasionally, you can keep automatic caching enabled and add code to the page to invalidate the cache when the page's data is expected to be updated.
Call the invalidate()
method from the wix-site-backend
module in your backend code.
Important:
The invalidate()
method invalidates the cache for the whole site, not just the page where you run the code.