Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 2.22 KB

File metadata and controls

75 lines (59 loc) · 2.22 KB

Cache Invalidation Logger Plugin

This Shopware 6 plugin logs cache invalidation events with detailed information about which tags are being invalidated and which code triggered the invalidation.

Features

  • Logs all cache invalidation events
  • Shows which cache tags are being invalidated
  • Displays the caller (class and method) that triggered the invalidation
  • Shows the call stack for debugging
  • Indicates whether invalidation is forced or delayed
  • Provides sample of tags when there are many

Installation

  1. Navigate to your Shopware installation directory
  2. Install the plugin:
    cd custom/plugins/CacheInvalidationLogger
    composer install
  3. Refresh the plugin list and install/activate the plugin:
    bin/console plugin:refresh
    bin/console plugin:install --activate CacheInvalidationLogger

Usage

Once activated, the plugin will automatically log all cache invalidation events. Check your logs to see entries like:

{
    "message": "Cache invalidation triggered",
    "context": {
        "tags": ["product-detail-123abc", "product-listing-category-456"],
        "force": false,
        "caller": "Shopware\\Core\\Framework\\Adapter\\Cache\\CacheInvalidationSubscriber::invalidateProduct",
        "call_stack": [
            "Shopware\\Core\\Framework\\Adapter\\Cache\\CacheInvalidationSubscriber::invalidateProduct",
            "Shopware\\Core\\Content\\Product\\DataAbstractionLayer\\ProductIndexer::handle"
        ],
        "tags_count": 2
    },
    "level": 200,
    "level_name": "INFO",
    "channel": "cache_invalidation"
}

Common Cache Tags

  • product-detail-{id} - Product detail pages
  • product-listing-{categoryId} - Product listing pages
  • navigation-{salesChannelId} - Navigation menus
  • category-{id} - Category pages
  • system.config-{salesChannelId} - System configuration
  • theme_scripts_{path} - Theme JavaScript/CSS

Configuration

The plugin creates a separate log file specifically for cache invalidation events:

  • Development: var/log/cache_dev.log
  • Production: var/log/cache_prod.log

To see the logs in real-time:

tail -f var/log/cache_dev.log

The logs are written in JSON format for easy parsing and analysis.

License

MIT