# Listing extrem langsam (Shopware 5.6.9)

**URL:** https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510
**Category:** Shopware 5
**Created:** [8. Mai 2021 um 18:05 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510 "2021-05-08T18:05:32Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pogolino](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pogolino](https://forum.shopware.com/u/pogolino)
#### Post date: [8. Mai 2021 um 18:05 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/1 "2021-05-08T18:05:32Z")

</div>

Ich habe rund 100’000 Artikel im Shop, davon etwa 60’000 aktiv. Keine Varianten Artikel.  
Nun habe ich das Problem dass beim Aufruf einer Kategorieseite sehr lange dauert wenn der HTTP-Cache ausgeschaltet ist.  
In einer Überkategorie mit 2311 Ergebnissen dauert es 30-60 Sekunden.  
Eine Unterkategorie mit 700 Artikel dauert rund 5-15 Sekunden.  
Eine Unterkategorie mit 11 Artikeln rund 2-3 Sekunden.

Der Server ist sehr schnell.  
Die SQL Time ist jeweils unter 0.01 ms, also kann es nicht die Datenbank sein.

Ich sehe mit dem Profiler Plugin dass **Enlight\_Controller\_Plugins\_ViewRenderer\_Bootstrap::onPostDispatch**  
sowie  
**Shopware\_Plugins\_Frontend\_Seo\_Bootstrap::onFilterRender**  
Praktisch all die Zeit verbrauchen.

Nun habe ich komplett alle Plugins (bis auf Profiler) deinstalliert / deaktiviert.  
Ich habe auf das Standard-Template gewechselt.

Doch das alles hat nichts gebracht. Was kann das sein?  
Merkwürdig ist dass die SQL Abfrage sehr schnell gehen, aber der Aufbau, je mehr Artikel es in der Kategorie hat, umso länger geht. Wenn ich dann aber einen Filter verwende, welcher Artikel mittels Ajax nachlädt, geht dies wiederum blitzschnell.

Ich wärme im Normalbetrieb den Cache auf mittels /bin/console sw:warm:http:cache -b 8 -k -o -t -n  
Das Aufwärmen aller 870 Kategorieseiten dauert dort nur rund 61 Sekunden!

 ![perf1](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/c/c18c6eb0683705187833726cca7345c374ee9439.jpeg)

---

<div class="post-metadata">

### Author: ![pogolino](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pogolino](https://forum.shopware.com/u/pogolino)
#### Post date: [9. Mai 2021 um 10:45 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/2 "2021-05-09T10:45:58Z")

</div>

Habe nun rausgefunden dass es am HtmlMinifier von Shopware liegt. Dieser wird bei viel Quellcode extrem langsam.  
Habe nun das file /engine/Shopware/Components/Template/HtmlMiniCompressor.php abgeändert und den Code hier verwendet: [https://stackoverflow.com/a/6225706](https://stackoverflow.com/a/6225706)

---

<div class="post-metadata">

### Author: ![Moin](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Moin](https://forum.shopware.com/u/Moin)
#### Post date: [10. Mai 2021 um 06:02 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/3 "2021-05-10T06:02:13Z")

</div>

> [@pogolino](#):
>
> HtmlMinifier

Wie hast du es herausgefunden? Welches Tool hast du eingesetzt?

VG

---

<div class="post-metadata">

### Author: ![pogolino](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pogolino](https://forum.shopware.com/u/pogolino)
#### Post date: [10. Mai 2021 um 11:01 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/4 "2021-05-10T11:01:00Z")

</div>

Ich habe mittels dem Profiler Plugin die Funktion ausfindig gemacht welche sehr lange braucht und mir dann diese genau angeschaut. So bin ich relativ schnell auf den HtmlMiniCompressor gestossen.

---

<div class="post-metadata">

### Author: ![CHSB](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@CHSB](https://forum.shopware.com/u/CHSB)
#### Post date: [27. Juni 2022 um 12:58 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/5 "2022-06-27T12:58:40Z")

</div>

Kannst du den Code deiner abgeänderten PHP Datei einmal posten?

---

<div class="post-metadata">

### Author: ![pogolino](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pogolino](https://forum.shopware.com/u/pogolino)
#### Post date: [17. November 2022 um 11:57 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/6 "2022-11-17T11:57:16Z")

</div>

/engine/Shopware/Components/Template/HtmlMiniCompressor.php

```auto
<?php
namespace Shopware\Components\Template;

class HtmlMinCompressor implements HtmlCompressorInterface
{
    public function minify(string $content): string
    {
        return myMinify($content);
    }
    
}     

    function myMinify($content) {

    //remove redundant (white-space) characters
    $replace = array(
        //remove tabs before and after HTML tags
        '/\>[^\S]+/s' => '>',
        '/[^\S]+\</s' => '<',
        //shorten multiple whitespace sequences; keep new-line characters because they matter in JS!!!
        '/([\t])+/s' => ' ',
        //remove leading and trailing spaces
        '/^([\t])+/m' => '',
        '/([\t])+$/m' => '',
        // remove JS line comments (simple only); do NOT remove lines containing URL (e.g. 'src="http://server.com/"')!!!
        '~//[a-zA-Z0-9]+$~m' => '',
        //remove empty lines (sequence of line-end and white-space characters)
        '/[\r\n]+([\t]?[\r\n]+)+/s' => "\n",
        //remove empty lines (between HTML tags); cannot remove just any line-end characters because in inline JS they can matter!
        '/\>[\r\n\t]+\</s' => '><',
        //remove "empty" lines containing only JS's block end character; join with next line (e.g. "}\n}\n</script>" --> "}}</script>"
        '/}[\r\n\t]+/s' => '}',
        '/}[\r\n\t]+,[\r\n\t]+/s' => '},',
        //remove new-line after JS's function or condition start; join with next line
        '/\)[\r\n\t]?{[\r\n\t]+/s' => '){',
        '/,[\r\n\t]?{[\r\n\t]+/s' => ',{',
        //remove new-line after JS's line end (only most obvious and safe cases)
        '/\),[\r\n\t]+/s' => '),'
         );
    $content = preg_replace(array_keys($replace), array_values($replace), $content);

    return $content;
  }

```

---

<div class="post-metadata">

### Author: ![anna.dick](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@anna.dick](https://forum.shopware.com/u/anna.dick)
#### Post date: [8. Juli 2023 um 15:11 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/7 "2023-07-08T15:11:28Z")

</div>

Der Code ist mega und hat uns sehr gut geholfen, allerdings ist dadurch ein Problem entstanden.

In dem Button „In den Warenkorb“ ist nun zusammengeschrieben „In denWarenkorb“ und im Kundenaccount ist Vor- und Nachname zusammengeschrieben. das sind zwei Punkte, die mir aufgefallen sind.

Liegt an der Zeile:

```
    //remove empty lines (between HTML tags); cannot remove just any line-end characters because in inline JS they can matter!
    '/\>[\r\n\t]+\</s' => '><',

```

Ich frage mich, warum an den beiden Stellen. Was ist hier anders, dass der Fehler passiert.

Jemand eine Ahnung wie man das löst? also klar hab die Zeile jetzt rausgenommen.

Aber, so dass die Funktion an anderen Stellen greift.

---

<div class="post-metadata">

### Author: ![energyinside](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@energyinside](https://forum.shopware.com/u/energyinside)
#### Post date: [24. Juli 2024 um 08:54 UTC](https://forum.shopware.com/t/listing-extrem-langsam-shopware-5-6-9/87510/8 "2024-07-24T08:54:38Z")

</div>

Hallo,

ich bin ziemlich neu in diesem Thema. Die Funktion im Shopware Backend (HTML Komprimierung aktivieren), sollte dabei angeschaltet sein?
