If you just uploaded a new modification script to OpenCart, or made some custom changes in template or admin panel, but the changes you made don't show up, there's a big chance that your changes require clearing OpenCart's cache.
Controlling cache in OpenCart is simple and straightforward, you don't need any special tools or programming knowledge. What you need to know is how to control cache in OpenCart. Here's what you'll learn today:
What is cache in general, and why it's useful
Cache is used in most of content management systems (CMS) and e-commerce platforms.
The idea is quite simple. When server is loading a single page (text page, product page, blog post etc.), it actually gathers and loads data from tens or even hundreds different sources. This data can be programming code from multiple files, multiple database query results, styling sheets etc.
Some part of this information is the same in almost every page. For example website's footer and header. So there should be no need to gather and process that constantly repeating information again on every single page.
This is there the cache is used. System creates temporary (and sometimes heavily optimized) files which already have "static" and repeating elements - so server needs to gather and process only the information that is changing from one page to another. Every other data is loaded from prebuilt cache files.
This functionality lets load web pages faster, and at the same time makes less work for for the server, so it can handle other requests easier, and work more efficiently.
What kind of cache OpenCart uses by default
By default any OpenCart 3.x version of OpenCart has 3 types of caching built-in:
Theme cache. This cache is used for loading theme files. So if you're making changes, for example in /admin .twig files, there's a chance that your changes will show up only after clearing theme cache in OpenCart.
SASS cache. SASS is used to process CSS code. None of the default OpenCart components use SASS, but there may be third party OpenCart extensions which use this functionality so you should clear this cache if you know (or just not sure) that it's used in any third party themes or extensions installed in your online store.
Modification cache. These cache files are specific to OpenCart. When you install a module which modifies any of the core OpenCart files (can be controller, model, template files - almost any file), OpenCart does not overwrite the original file. It creates a cache file with all the modifications applied. So when you ask OpenCart to load a specific page, first it loads modified cache files, and only then, if modifications were not found, loads the original core files. This way you can modify core functionality without breaking or overprocessing the original files.
OpenCart 2.x versions use only Modification cache.
Previous OpenCart versions did not have any of these cache mechanisms built-in.
Optionally any OpenCart version can have vQmod cache if you have vQmod installed in your online store.
How to enable, disable and refresh theme and SASS cache in OpenCart
If you just created new online store using v126.96.36.199 or later OpenCart version then you'll have all three caching systems enabled and running by default.
If you want to clear, enable or disable Theme and SASS cache, you need to open your OpenCart store's Dashboard. Click the cog-wheel button at the top right of the Dashboard page to open cache settings window.
There you'll be able to:
enable or disable Theme and SASS cache by turning them on or off
refresh both SASS and Theme cache by clicking Refresh button
How to clear Modification cache in OpenCart
There is no way to disable Modification cache - you either enable or disable any of the extension mods individually. But after uploading new modifications or updating them you need to refresh the Modification cache to make sure that all the changes will be loaded next time someone visits your store.
To do that go to Extensions >> Modifications in OpenCart admin menu, and click Refresh button at the top right of the page.
That's it - modification cache is clear, and the new modification files will be generated automatically.
How to clear vQmod cache in OpenCart (optional)
If you have vQmod installed in your OpenCart store, you should also know that vQmod has it's own "modification" cache folder.
You can access it using Filezilla or similar FTP client. VQmod cache folder is named vqcache and it can be located in /*your-opencart-website*/vqmod/ folder in your FTP. Normally you don't need to clear vQmod cache - it refreshes automatically once you update any of the vqmod scripts.
In some rare cases vQmod might not refresh it's cache - you may need to delete all the content in vqmod/vqcache/ folder manually. Just make sure to make a backup of the folder content in case something goes wrong. Most of these cases happen not because vQmod fails, but because some buggy third party mod breaks something important in OpenCart system.
What if you still see old code or site content after clearing cache
If you cleared all the cache files but you still see old data or website content instead of the new one, make sure you don't have any third party speed-up or caching extensions enabled in your system. Some third party OpenCart templates also can have their own caching functions. So make sure to refresh cache there too.
If even that does not help, you should check if your hosting server does not have it's own caching enabled. Sometimes it can be server settings (talk to your hosting provider when you notice delays between updating mods and seeing the results in action). Sometimes it's CDN cache, if you use CDN service.
And of course you should not forget to refresh your browser cache by hitting CTRL + F5 a few times. Maybe everything work as it should, but your broswer shows old website version.