mage2tv / magento-cache-clean

A faster drop in replacement for bin/magento cache:clean with file watcher
BSD 3-Clause "New" or "Revised" License
527 stars 61 forks source link

Clear appropriate caches when watching csp_whitelist.xml #86

Closed complexthings closed 3 years ago

complexthings commented 3 years ago

We run mage2tv/magento-cache-clean through node/gulp in warden using the following (paired down):

import chalk from 'chalk';
import { spawn } from 'child_process';

const cacheClean = spawn('vendor/bin/cache-clean.js', ['--watch']);

cacheClean.stdout.on('data', (data) => {
    console.log(chalk.blue(`Magento Cache Clean: ${data}`));
});

cacheClean.stderr.on('data', (data) => {
    console.log(chalk.red(`Magento Cache CLean: ${data}`));
});

cacheClean.on('close', (code) => {
    console.log(chalk.yellow(`Magento Cache Clean exited with code ${code}`));
});

When I edit a csp_whitelist.xml I see the following output:

Magento Cache Clean: 18:36:50 Cleaning id(s): global::csp_whitelist_config frontend::csp_whitelist_config adminhtml::csp_whitelist_config webapi_rest::csp_whitelist_config webapi_soap::csp_whitelist_config graphql::csp_whitelist_config

But if I refresh the page I will still see the same items reported as being refrused. Yet if I run just straight up vendor/bin/cache-clean.js Flushing all the caches and then refresh my browser the items no longer report. I think there's some additional caches that need to be flushed when you watch and modify a csp_whitelist.xml

Also, this is one of my favorite tools, keep up the great work bud!

Vinai commented 3 years ago

Hey, thanks for the report! Can you please do me a favor and check if running cache-clean.js full_page (to only flush the FPC) also does the trick? Maybe varnish is storing the response with the csp headers?

I’ll definitely dig into this, too, in order to find the cache causing the issue. Thanks!

complexthings commented 3 years ago

@Vinai looks like vendor/bin/cache-clean.js config full_page works.

Vinai commented 3 years ago

Hey @complexthings , sorry for the delay, I've been busy with the Hyva_Admin module....

Anyhow, I've just released 1.0.34 - could you please check if that solves the issue? Many cheers and all the best!

Vinai commented 3 years ago

Oh yeah, sorry, to upgrade a global installation, please use composer global require mage2tv/magento-cache-clean:1.0.34

For a in-project installation, the same without the global works: composer require mage2tv/magento-cache-clean:1.0.34

Vinai commented 3 years ago

I'm closing this issue, since I believe it's been fixed by 1.0.34 and I haven't heard back. If it still doesn't work, please reopen!