commercetools / commercetools-sunrise-java

The next generation shop framework by commercetools
https://demo.commercetools.com
Apache License 2.0
46 stars 35 forks source link

Facet values remain checked when back button of a browser is used #566

Open selo-ecube opened 7 years ago

selo-ecube commented 7 years ago

Thanks @mmoelli for bringing #561 to attention again, which helped us to solve the following issue. Maybe it is possible to solve it in general.

Please consider the following scenario that applies to our own Sunrise-based shop as well as to demo.commercetools.com:

  1. Perform a search (no facet value is selected), yielding list of results List1.
  2. Select a facet value Value1, which will reload the page and yield list of results List2.
  3. Hit the back button of the browser. The page will not be reloaded, Value1 is selected but List1 is shown.

This problem can be solved by adding the @NoCache annotation to the controller of the product overview controller (and any other controller that lists facets). Then in step 3, the page will be reloaded, and thereafter no facet value will be selected but List1 will be shown.

@lauraluiz Is that the solution you favour? It could be applied in commercetools-sunrise-java-starter. Do you think it makes sense to add documentation on Caching in commercetools-sunrise-java?

Thanks!

lauraluiz commented 7 years ago

@selo-ecube yes, that's a solution anybody can apply now. It has already been applied to my working branch for some time already, but I still need some time to apply it to the demo and Starter because now the priority is to provide v1.0.0 and hopefully any person having this problem in the next weeks will find this issue.

But as I said in the other issue, this has performance issues, and the only good solution comes from a change on the frontend side.

In any case, I'll leave this issue open to remember to apply it everywhere and provide some documentation mentioning the cache annotations. The idea was to provide caching annotations suitable for other situations too, but finding the right cache headers for every situation is a hard task :)

lauraluiz commented 7 years ago

Already applied everywhere since v1.0.0-M1, missing documentation.