Linked Questions
20 questions linked to/from How to use HTTP cache headers with PHP
22 votes
2 answers
90k views
How to destroy the session cookie correctly with PHP?
I'm trying to correctly log out of an admin user. Here is my function: function logout() { $_SESSION = array(); //destroy all of the session variables if (ini_get("session.use_cookies")) { ...
5 votes
4 answers
7k views
What's the suggested way of storing a resource ETag?
Where should I store the ETag for a given resource? Approach A: compute on the fly Get the resource and compute the ETag on the fly upon each request: $resource = $repository->findByPK($id); // ...
5 votes
3 answers
1k views
What’s the right way to embed PHP code in my CSS and JavaScript files?
Like everyone else I'm storing my site`s display information in style sheet files. And I want to create back-end cms so users will be able to, for example, change < h1 > color, size etc. So, what'...
5 votes
3 answers
4k views
PHP cache header override
I've been through over 100 answers here, lots to try, NOTHING working?? Have a PHP based site. I need caching OFF for all .php files EXCEPT A SELECT FEW. So, in .htaccess, I have the following: ...
3 votes
1 answer
6k views
php: how to correctly remove all cookies?
Ideally, to delete cookie in php, one should set exactly the same parameters when the cookie was created, except value and expire time: Creating cookie: setcookie('cookie1', 'value1', time()+10000, '...
3 votes
1 answer
8k views
Force browser to cache PHP generated JavaScript
There is a lot of advice how to use headers to prevent the browser from caching a file. I wish to do the opposite. The cache.php file below never changes. I've tested this using FF, Chrome, and FF, ...
1 vote
2 answers
4k views
Faster way to read and output images in browser with PHP
I am reading images from minimum of 1x1 pixel to maximum of 1600x1600 pixels. I have written three PHP methods and are working perfectly. // using FGC function output_fgc($filename) { header("...
1 vote
2 answers
2k views
readfile/fpassthru web caching
I have noticed that files delivered by PHP through readfile or fpassthru techniques are never cached by the browser. How can I "encourage" browsers to cache items delivered via these methods?
1 vote
4 answers
181 views
Preventing the browser caching a linked file
I've been tasked to maintain a PHP website with a function which automatically generates RTF files and provides a link to download. Each time the previously generated file is overwritten by the new ...
0 votes
6 answers
2k views
How to logout properly (PHP)
When I press the login button, it deletes the cookie redirects to the main page. It works perfectly. But when I press the "back" button (or backspace key), the logged in page still shows up. I want ...
2 votes
2 answers
1k views
ASP.NET Master Page equivalent for HTML/PHP websites
I have a website in which most of the content like the sidebar, the background etc. is similar across most of the pages in the sites. In ASP.NET, for such a case there are master pages. What's the ...
0 votes
1 answer
2k views
AngularJS ng-repeat image loading issue
I've recently started to use AngularJS on my projects and I've come across a big problem using ngRepeat to load thumbnails from a dynamic array into a DIV. Since I won't be explaining the entire ...
2 votes
2 answers
881 views
Check if page exists in cache, Windows 8 app
Is there a way to check if page/frame in Windows 8 application exists in cache? Let's assume I have two pages: Home and Clients (navigation cache enabled). When I navigate to clients from home (by ...
0 votes
1 answer
589 views
Mozilla doesn't "Refresh" the page
I have a page with keith-wood's datepicker, and jqplot graphs. Basically, the date picker 1 is set to todays date by default, and date picker 2 is set to a day before. If you select a date in ...
0 votes
1 answer
542 views
Making a dynamic site cache able? PHP
i'm wondering to generate cache pages of my website to avoid same queries again and again. there's almost 80% of queries fetching data that is almost not change able in near future (if cache system ...