Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page expiry - PHP/CakePHP and Internet Explorer

Tags:

php

cakephp

I have a search box on my site, whereby the user enters a term and results are displayed. When they click one of the results (a product) they get taken to the product page. When they then hit the back button, they get shown a "Warning: this page has expired" message.

I am using CakePHP on Apache, and have been advised that I need to change session.cache_control? I have tried chaning it to private in htaccess, but it does not seem to have helped.

Any help much appreciated.

Cheers, D

like image 470
iamdash Avatar asked Feb 01 '26 12:02

iamdash


1 Answers

This is nothing to do with CakePHP nor sessions. Indeed, the issue arises in all web programming languages.

The solution is to make the search results page cacheable - I would imagine that you're not updating your catalog every 5 minutes?

To make it cacheable you need to ensure that the search terms are sent using a GET rather than a POST, then set the right headers to enable the browser to cache the page, e.g.

 header('Cache-Control: max-age=360'); // allows browser to keep for 1 hour

....and if you're using sessions which may constrict the visiblity of certain products in the search:

 header('Varies: Cookie');

C.

like image 171
symcbean Avatar answered Feb 03 '26 02:02

symcbean