Caching Issue

I'm making an add-on which adds a condition to the catalog promotions that will enable a user to have a promotion activate if the URL contains a given value.

I'm running into a caching issue...

When accessing a page with the special value in the URL, (and there is already a cached version of the page) the system serves the cached version which shows the regular price (not the promo price).

When accessing a page with the special value in the URL (and there is no cached version of the given page) the promo price is shown correctly, but thereafter, the page will continue the show the promo pricing even when the page is accessed without the special value in the URL.

The issue dose not occur when "Rebuild cache automatically" is on or when testing with users logged in.

How can we avoid caching and using caches when the promotion is applied?

Many thanks

Are you using a 3rd party caching mechanism? Csc cache only caches layout, not data.

Are you using a 3rd party caching mechanism? Csc cache only caches layout, not data.

I'm using the default setup ($config['cache_backend'] = 'file') no 3rd party caching mechanism.

Why do you say that "Csc cache only caches layout, not data" see "/var/cache/registry/block_content_main_products.view/", it clearly has product data?

I know I can set 'disable_block_cache' => true but I'm wondering if there is a way to force the system to load a given page fresh (not from the cache) (to use when a promo URL is detected) and also have the system not cache a given page (when a promo ULR is used)

It seems that logged in used already use such functionality (promos that depend on a user group, for example, are only severed to the given user without any caching issues).

Why do you say that "Csc cache only caches layout, not data" see "/var/cache/registry/block_content_main_products.view/", it clearly has product data?


I thought you referring to a 'template' when using the term 'page'. Blocks can contain dynamic content if written to do so or have a filling type that implies data.

I know I can set 'disable_block_cache' => true but I'm wondering if there is a way to force the system to load a given page fresh (not from the cache) (to use when a promo URL is detected) and also have the system not cache a given page (when a promo ULR is used)

It seems that logged in used already use such functionality (promos that depend on a user group, for example, are only severed to the given user without any caching issues).

I would have that URL (SEO name) refer to a 'dispatch' request. I.e. for the /cart page, it equates to dispatch=checkout.cart.

Then the controller can supply the appropriate data (like force the use of a coupon code to trigger a promotion, etc.).

So as an example, a dispatch=my_changes.my-promotion would utilize the my_changes controller (addon) with a $mode of 'my-promotion'. That controller can then decide whether to display a custom page (addons/my_changes/views/my_changes/my-promotion.tpl) or redirect to a different page.

Thanks for your reply,

We're looking to be able to add the "special value to the URL" for any existing page on the site (home, category, product details etc.) so that the url may look like www.domain.com/?special or www.domain.com/category/product-name.html?special etc., so I don't think a custom dispatch is not an option.

​The functionality we're looking for seems to exist when a user is logged in, in which case,

1. Fresh block content is loaded (not from the cache)

2. The fresh block content that is loaded for the logged in user is not cached (so that other visitors will not receive the logged in users block content).

Any ideas?

Okay, so you are adding a parameter to the URL (technically then a URI).
Then add a addons/my_changes/controllers/frontend/init.post.php with code something like:

if( !defined(‘BOOTSTRAP’) ) die(‘Access denied’);

if( isset($_REQUEST[‘special’]) && @$_SERVER[‘REQUEST_METHOD’] == ‘GET’ && !defined(‘AJAX_REQUEST’])) {
// Do your special processing here.
}
return array(CONTROLLER_STATUS_OK);