mage2tv / magento-cache-clean

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

Support alternate Varnish ports #99

Closed joeshelton-wagento closed 2 years ago

joeshelton-wagento commented 2 years ago

When using the following configuration...

    ...
    'http_cache_hosts' => [
        [
            'host' => 'localhost:8080'
        ]
    ],
    ...

...a full page cache clear does not connect to Varnish using the correct port. Debugging info follows.

$ vendor/bin/cache-clear.js full_page Magento dir /Volumes/ProjectFiles/cwd 15:15:55 Cleaning cache type(s) full_page 15:15:55 Using :page_cache cache backend Reading app config by shelling out to php 15:15:55 Cache storage {:idprefix f53, :backend Magento\Framework\Cache\Backend\Redis, :backend_options {:server redis, :database 6, :port 6379, :password , :compress_data 0, :compression_lib }} 15:15:55 Flushing redis db 6 Reading app config by shelling out to php 15:15:55 Varnish request: #js {:protocol http:, :hostname localhost:8080, :port 80, :method PURGE, :path /, :headers #js {:X-Magento-Tags-Pattern .*}, :timeout 10000} 15:15:55 Varnish request error: getaddrinfo ENOTFOUND localhost:8080 15:15:55 No further Varnish PURGEs will be attempted 15:15:55 Disconnecting redis client

Also, there is no feedback that the connection to Varnish failed. But, that's probably a separate issue.

Vinai commented 2 years ago

Thanks for the issue @joeshelton-wagento!

As a workaround, please use the syntax that specifies the port as a separate property.

    'http_cache_hosts' => [
        [
            'host' => 'varnish',
            'port' => '80'
        ]
    ],

I'll add the ability to parse the port from the host in the next release.

Vinai commented 2 years ago

Released in 1.0.43

joeshelton-wagento commented 2 years ago

Oh, I didn't realize there was a more proper format for the port. But, the funny thing is, bin/magento cache:clean full_page works with the combined format. So I thought the cache clean tool should likewise work.

Many thanks!