0

My situation is as follows:

  • You add a Product to your cart.
  • If you have not added an ExtraProduct, you get to see a page to add an ExtraProduct.
  • If you have added it and end up on the ExtraProductPage I redirect you one step forward.

The issue I'm having is that if a user presses 'back' in the browser, it loads the page from buffer (or at least it does in Firefox). Because the browser loads it from cache, my PHP never gets fired, so no redirect (which I do want).

The headers for this page:

Cache-Control max-age=0, must-revalidate, private, s-maxage=-1
Expires Wed, 15 Jan 2020 12:44:52 GMT (timestamp of the request)

Yet, it keeps buffering. I want to turn the buffering off for this specific route only. Any suggestions?
I can do some tinkering with javascript and a onready, but I prefer to keep it serverside. Thanks.

NOTE: MY question is not a duplicate of the linked one because I want a serverside, PHP symfony solution, not javascript.

Martijn
  • 15,791
  • 4
  • 36
  • 68
  • Hi yivi, thanks for the edit, but I'm using the Symfony framework, might be a relevant tag :) – Martijn Jan 15 '20 at 13:17
  • 1
    @Martijn Er, if their browser never hits the PHP portion, it doesn't matter what PHP framework you use – Machavity Jan 15 '20 at 13:26
  • Im looking for a way to set a "do not buffer" in PHP so the browser understands that it should not buffer :) – Martijn Jan 15 '20 at 13:31
  • 1
    I think you had to emphasize the symfony requirement a little more in the first place. I voted to reopen your post. – FatihAkici Jan 15 '20 at 15:10
  • I had the symfony tag and the "javascript tinkering" in my answer :) I added it back after an edit took it out and explained it (see my first comment). Not really sure what else I coul do to avoid this. – Martijn Jan 15 '20 at 15:20
  • I'm sorry, but there is nothing "symfony" or "php" about the question. It is either _"what headers should I send to indicate that pages should not be cached by the browser?"_ (there is an answer in the dupe, and more [here](https://stackoverflow.com/questions/2990307/) which basically echoes what you are trying); or _"how do I force the client to refresh on going back on history?"_ (the current dupe). There is nothing PHP/Symfony about the issue. You already know how to send headers, and the matter is not backend dependant. – yivi Jan 15 '20 at 15:39
  • But I dont want to detect wether the user has pressed 'back'. I want to send a header or something to tell the browser never to show a buffered version, however way you navigate back. And setting headers is not a JS task. – Martijn Jan 15 '20 at 16:09
  • No, it's a backend task. But it does not depend on the backend you are using. It's the same if you are using Symfony or .NET or Java. And there is an answer in the linked dupe that mention the headers (as I said in my previous comment), which match the ones you say you are trying to send. Also in the other question I just linked. In any case, the question and its possible answers do not depend on PHP or Symfony. – yivi Jan 15 '20 at 16:15

0 Answers0