PHP and Caching Issues

Back in the day when webpages were nothing more than HTML, caching was a very handy feature. Browsers simply checked with the server to see if there were any updates to the page and in the event there weren’t any, picked up the page from the cache and displayed it. This was especially useful because in those days, internet access was via Dial-Up Modems. Transferring pages that were full of graphics was time consuming and took up all the bandwidth.

However, the advent of PHP and Dynamic webpages has nullified the use of the browser cache. This is because of two particular problems.
1. When the server gets a request for a page, the process of parsing the scripts has to be completed before the page can be served up. Therefore a delay factor comes into play. Although this may not be a problem when dealing with small scripts, complex scripts will take a lot more time. Therefore the user will always experience a noticeable lag between the request and delivery of the page.

2. Generally a web server, such as Apache, informs the browser of any changes to a page using the time of modification of the file. With PHP based pages, the script is not likely to change very frequently. But the content will change and the server has no way of knowing if it has changed because the content is held in a database. In this case the server sends no information regarding the modification time and always served a fresh copy of the page.