Speed
On a local test shop (OpenCart 4.1, XAMPP, the demo catalogue) the home page went from about 650 ms to about 58 ms, a product page from about 730 ms to about 61 ms, and a category page from about 620 ms to about 50 ms (median of five requests). Your numbers will differ with your server, but a cached page skips almost all of the work.
What is cached
- Home, category, product, brand, special offers and information pages (you can edit the list of pages).
- One copy for each language, currency and address, so every visitor sees the right prices.
- The same cached page serves every guest.
What is never cached
- Logged-in customers, and any visitor with products in the cart or on a wish list or compare list.
- Pages that carry a message (for example "product added"), forms, ajax requests and any request that is not a plain GET.
- Search results, the cart, the checkout and the account pages.
- A page whose address has a parameter you did not allow, so nobody can fill the folder with copies. Pages that answer 404 or redirect are not stored either.
- A logged-in admin in the same browser always sees the live shop (not possible to detect on OpenCart 4.0.x).
Automatic clearing
- Saving or deleting a product, category, brand, information page, banner, layout, currency rate or setting in the admin clears the cache. On 2.3 and 3.0 saving one product keeps the pages of other products. On 4.x saving a product also clears every page, because the product address is saved with it.
- A new order status (for example a paid order that lowers the stock) clears the pages of the products in that order.
- A page is made again after the time you set (60 seconds to 7 days).
- A "Clear the cache" button, and a limit for the number of stored pages.
Admin
A page shows how many pages are cached and how big the folder is. Admin permissions: opening needs view rights, changing the settings and clearing need change rights. The cache is off after install until you switch it on. Uninstall removes every cached page.
Works with
OpenCart 2.3, 3.0, 4.0 and 4.1 (one zip for each).
Good to know
Screenshots are still to be added.
- A timed special price (with start and end dates) can show for up to the "keep a page for" time after it starts or ends. Choose a time shorter than your shortest timed offer.
- Pages that a bulk import, a feed or a direct database change updates are not cleared by themselves: press Clear the cache after them.
- A theme or module that puts something personal on a page for guests (for example the visitor's country) should have that page removed from the list.
- The cached pages are kept in the shop storage folder, outside the web root.
- The first request after a clear is a normal slow one; every later guest gets the cached page. The answer carries an X-Page-Cache: HIT or MISS header so you can check it.
- Tested on the four versions with the real admin installer, 67 to 76 checks each: MISS then HIT with identical pages, other guests, parameter order, every page kind, the pages and requests that are never cached, a cart, a second currency, admin, expiry, the file limit, a product and an information page saved through the real admin forms, a real order history call, permissions, uninstall and reinstall.