View Issue Details

IDProjectCategoryView StatusLast Update
0006365OXID eShop (all versions)4.08. Cachepublic2024-03-13 10:24
Reporterhendrikfreytag Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version4.9.7 / 5.2.7 
Summary0006365: Varnish cache is not invalidated when using the framework without oxshopcontrol
DescriptionTo use the shop framework you have to include bootstrap.php. So you can use the models to change shop data. If you change and save an article via a command line script which includes bootstrap.php the shop framework will collect URLs to invalidate in varnish. But this URL pool is only collected and the execution of the invalidation will never be done.

The problem is that this invalidation execution is done in \oxShopControl::_process. But this function is not executed when using the shop framework in a script.

This does not only affect own command line scripts this also affects the ERP interface of OXID. When using the ERP interface the varnish cache is not invalidated.
Steps To Reproduce- install and activate varnish
- look on a article detail page to load it in cache
- change price of the article via ERP interface or command line script
- reload article page

-> Cached version with old price will be shown.

(Use attached test script, it will change TRAPEZ ION MADTRIXX.)
Additional InformationThis has to solved in bootstrap.php, because this is the only thing you need to initialize the shop framework. The bootstrap.php is executed in the start of the script and not at the end, but you need to execute the invalidation at the end. A possibility to solve this is to use register_shutdown_function (http://php.net/manual/de/function.register-shutdown-function.php) to register a function which executed the following lines at the end of script execution:

$oxReverseProxyBackend = oxRegistry::get('oxReverseProxyBackend');
$oxReverseProxyBackend->execute();

Maybe this could be added to oxfunctions.php or another place, but it has to be made sure that this will be initialized in the bootstrap.php.
TagsEE, ERP, Performance and Caching Rework, Varnish
Attached Files
test.php (213 bytes)
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Activities

keywan.ghadami

2016-04-08 11:53

reporter   ~0011526

Last edited: 2016-04-08 16:49

register_shutdown_function
will not work good together with php fpm, because there register function may called a long time after the request.

So i have to do cache invalidation manually, but interesting is that in php fpm environments you can do something like:

    fastcgi_finish_request();
    $oxReverseProxyBackend = oxRegistry::get('oxReverseProxyBackend');
    $oxReverseProxyBackend->execute();

so clients will not wait while varnish cache is being cleared.

keywan.ghadami

2016-04-08 16:50

reporter   ~0011529

see pull request for ERP
https://github.com/OXID-eSales/erp/pull/13