This is the first of what I hope will be a series of posts showing snippets of code from my personal library. My intention is to highlight useful techniques I've developed or picked up over the years. Comments, questions, suggestions and requests are welcomed.
This first snippet is a simple function to set appropriate expiry headers. Simply pass it a time period in seconds or a unix timestamp to set the expiry to some time in the future, or 0 to expire the page immediately.
Note that since this function sets headers you must not call it after output has been sent to the browser. If headers have already been sent (i.e. output has occurred) this function will silently have no effect.