Skip to content
shopware·24.10.2025·3 min read

Shopware 6 Developer Performance Guide - Essential Improvements and Fixes

Performance optimization is crucial for any e-commerce platform. Here are the most impactful performance improvements and fixes for Shopware 6 developers.

Shopware 6 Developer Performance Guide - Essential Improvements and Fixes

Introduction

Performance optimization is crucial for any e-commerce platform. Here are the most impactful performance improvements and fixes for Shopware 6 developers. These optimizations can significantly improve your store's loading times and user experience.

1. Enable HTTP Cache

The HTTP cache is your first line of defense for performance. Configure it properly in your .env file:

SHOPWARE_HTTP_CACHE_ENABLED=1
SHOPWARE_HTTP_DEFAULT_TTL=7200

For dynamic content, use cache invalidation strategically:

use Shopware\Core\Framework\Adapter\Cache\CacheInvalidator;

$this->cacheInvalidator->invalidate([
    'product-' . $productId,
    'navigation'
]);

2. Optimize Database Queries

Avoid N+1 queries by using associations properly:

// Bad: Multiple queries
$products = $this->productRepository->search($criteria, $context);
foreach ($products as $product) {
    $manufacturer = $product->getManufacturer(); // Extra query per product
}

// Good: Single query with associations
$criteria->addAssociation('manufacturer');
$products = $this->productRepository->search($criteria, $context);

3. Use Entity Search for Better Performance

Leverage the DAL (Data Abstraction Layer) efficiently:

$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('active', true));
$criteria->setLimit(20);
$criteria->setOffset(0);

// Add only needed associations
$criteria->addAssociation('cover');

$products = $this->productRepository->search($criteria, $context);

4. Implement Proper Indexing

Ensure your custom entities are indexed correctly:

use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexer;

class CustomEntityIndexer extends EntityIndexer
{
    public function update(EntityWrittenContainerEvent $event): void
    {
        // Implement efficient indexing logic
    }
}

5. Optimize Asset Loading

Minimize JavaScript and CSS by configuring the theme properly:

// In your theme's webpack configuration
module.exports = {
  optimization: {
    minimize: true,
    splitChunks: {
      chunks: 'all',
    },
  },
}

6. Use Message Queue for Heavy Operations

Offload time-consuming tasks to the message queue:

$this->messageBus->dispatch(
    new ProductExportMessage($exportId)
);

Configure workers in your deployment:

php bin/console messenger:consume async --time-limit=3600

7. Enable Redis for Cache and Sessions

Configure Redis in .env:

REDIS_CACHE_HOST=127.0.0.1
REDIS_CACHE_PORT=6379
APP_CACHE_ADAPTER=cache.adapter.redis

SESSION_HANDLER=redis
SESSION_HANDLER_ID=redis://127.0.0.1:6379

8. Database Connection Pooling

Use persistent connections for better database performance:

# config/packages/doctrine.yaml
doctrine:
  dbal:
    options:
      !php/const PDO::ATTR_PERSISTENT: true

9. Profiler Management

Disable the profiler in production:

APP_ENV=prod
SHOPWARE_PROFILER_ENABLED=0

10. CDN Integration

Serve static assets through a CDN by configuring your shopware.yaml:

shopware:
  cdn:
    url: 'https://cdn.your-domain.com'
    strategy: 'physical_filename'

Key Performance Metrics to Monitor

  • Time to First Byte (TTFB): Should be under 200ms
  • Page Load Time: Target under 2 seconds
  • Database Query Time: Keep under 50ms per request
  • Cache Hit Ratio: Aim for 80%+

Quick Wins Checklist

  • ✓ Enable HTTP cache
  • ✓ Configure Redis
  • ✓ Optimize images (WebP format)
  • ✓ Enable lazy loading for images
  • ✓ Minify CSS and JavaScript
  • ✓ Use proper indexing
  • ✓ Implement message queues
  • ✓ Monitor slow queries

Conclusion

Performance optimization is an ongoing process. Start with the quick wins like enabling HTTP cache and Redis, then gradually implement more advanced optimizations. Always measure before and after to validate your improvements.

Remember: Premature optimization is the root of all evil, but ignoring performance is the root of all user frustration.

Enjoyed this?

Get new posts as they land.

Subscribe via RSS

Keep reading