Is there way to add the same block to cache in different versions to cache, for example for different sorting in products' grid, but for the same request params - for example random sorting, which should be different every time? It would be good to have for example 10-20 versions of block with different order of products and just take different versions from cache. It is not good solution to clean cache for every request with random sorting parameter.
1 Answer
For random sorting, i prefer to have 1 cached version of the block, and use javascript to shuffle the items client side. This reduces the load on the server and the result is the same for the customer.
This is assuming that shuffling the shown results (limited to the items on page 1) is sufficient.
If you want to shuffle more products, spanning multiple result pages, that would be more difficult are require server side customization.
-
yes - JS is server is 1 page limited, that is the point maybe having some infite scroll extension there it could be done, as extension like that usually loads pages via ajax and caches next page Commented Feb 12, 2017 at 15:45
-
It really depends how random you want to make this. In my experience some random effect is usually enough and not worth the extra server load. Also, randomizing results can be frustrating as customers see something on your page, but cannot find it again on a second visit.– WouterCommented Feb 12, 2017 at 17:17
-
Of course random sorting is not intented to be default one. It is worth considering if our approach is not enough. Commented Feb 13, 2017 at 8:54