Clientside Cache Control
Users hate your cache
Users don’t like caching! They want to see the changes immediately. Otherwise they get confused and write you bug tickets or flame mails. But if you do not use caching the user comes and make your CPU’s burning. If your site is down you not only get mails from your users, but also from your management.
Office 2010 Pro Discount Autodesk Softimage 2012 (32-bit) Autodesk Maya 2013 (64-bit) Office 2007 Professional Product Key Photoshop Cs5 Upgrade Buy Windows Xp Sp3 Windows 8 64 Bit Oem Software Purchase Purchase Steinberg Cubase 5 Buy Windows 7 Academic Buy Windows 7 Professional Product Key Buy Windows 7 Bulk Office 2007 Ultimate Price Cheap Netbooks Uk Windows 7 Xilisoft Audio Converter 2.1 Buy Windows 8 Buy Windows 7 Download Office 2010 Price Buy Windows 7 Canada Windows 7 Update Downloads
Cheap Windows Office 2007
Windows Xp Pro Price Best Price Adobe Robohelp 7 Graphisoft Archicad 14 (32-bit) Windows 7 64 Cheap Corp Microsoft Office Visio Standard 2010 Buy Full Version Buy Windows Xp 64 Bit Oem Microsoft Office Price Buy Windows 7 Service Pack 1 Buy Windows 7 Games Microsoft Office 2007 Buy Autodesk Autocad Mechanical 2011 Buy Windows 7 Tesco Microsoft Office 2004 Student And Teacher Edition Mac Adobe Creative Suite 5.5 Design Premium Microsoft Office Visio Professional 2010 Best Buy Oem Soft Download Microsoft Office 2010 Professional (32-bit) Best Price Buy Photoshop Elements 8 Windows Purchase Emco Remote Desktop Adobe Photoshop Oem Buy Windows 7 License Key Only Cheap Windows 7 Ultimate Key Microsoft Office 2010 Professional (64-bit) Cheap Rosettastone German Windows Xp Sale Cakewalk Sonar 7 Producer Edition Cheap Autodesk Showcase 2012 Buy Microsoft Office 2003 Cheap Autodesk Lustre 2009 Office 2010 Student Discount Windows 8 Preview KeyAutocad 2010 Uninstaller Download
Purchase Photoshop Cs5 Were Buy Windows 7 Cheap Corel Paintshop Photo Pro X4 Microsoft Windows 7 Home Premium (64 Bit) Windows 7 Ultimate Online Download Adobe Flash Professional Cs5 Mac Adobe Flash Professional Cs5.5 Purchase Windows 8 Key Windows 7 Professional Download Adobe Creative Suite 4 Web Premium Mac Sony Cinescore Buy Office 2010 Oem Autodesk Maya 2011 (64-bit) Best Buy Microsoft Office 2010 Purchase Navisworks Review 2012 Best Buy Windows 8 Upgrade Microsoft Office Excel 2010 Home And Student (64-bit) Download Windows 7 Loader Buy Windows 8 Laptop Cheap Office 2012 For Mac Oem Photoshop Cs6 Discount Microsoft Windows Server 2008 R2 Enterprise (64 Bit) Purchase Full Oem Version Cheap Office 2007 Standard Autodesk Navisworks Manage 2012 (32-bit) Download Oem Software Office 2010 Infopath (64-bit) Buy Microsoft Windows 7 Professional Adobe Creative Suite 6 Design Web Premium Windows Xp Pro Price Purchase Tomtom Map Of United Kingdom Republic Of Ireland Photoshop Cs6 Oem Purchase Online Creative Suite 6 Master Collection Sony Cinescore Autodesk Inventor Publisher 2011 Can I Still Buy Windows Xp 2012 Discount Microsoft Office Professional Cheapest Adobe Creative Suite 6 Master Collection Cheap Mac Os X 10.7 Lion Best Buy Windows 8 Microsoft Visual Studio 2010 Ultimate Trend Micro Titanium Maximum Security 2012 (64 Bit) Buy Windows 7 Computer Buy Windows 7 Home Premium 32 Bit Web Store Adobe Cs5 Design Premium Microsoft Office 2010 Home And Student (32-bit) Windows 7 Ultimate Not Genuine Buy Windows 7 Tesco Buy Windows 7 Home Premium Product Key Adobe Photoshop Cs5 Upgrade Windows 7 Cheap Upgrade Microsoft Office 2010 Professional Download Buy Windows 8 For 14.99 Adobe Creative Suite 6 Master Collection Discount Buy Os X 10.6 Buy Photoshop Cs5 Extended Buy Windows 8 Price Cheap Microsoft Windows Xp Cheap Word 2010 Roxio Easy Media Creator Suite 10 Adobe Illustrator Cs4 Mac Adobe Creative Suite 4 Design Standard Buy Windows Vista Download Autodesk Alias Surface 2012 (64-bit) Microsoft Office 2010 Professional Discount Adobe Incopy Cs6 Mac Autodesk Motionbuilder 2012 (64-bit) Cheap Archicad 10 Oem Windows 7 Download Buy Windows 7 Enterprise Buy Gta 4 Windows Purchase Adobe Cs5 Web Premium On Line Cheap Windows Xp Computer Software Windows 7 Professional Adobe Cs5 Master Collection Mac Price Buy Mac Os Lion Microsoft Office 2010 Professional Oem Native Instruments Traktor Dj Studio 3.4 Mac Buy Windows 7 In Bulk Buy Windows 7 John Lewis Buy Windows Xp Ebay Buy Windows 7 Nigeria Buy Windows 7 CoaMicrosoft Office Visio Premium 2010 (32-bit)
Buy Windows 7 Key Code Cheap Windows 7 Professional Altova Umodel Enterprise 2009 Cheapest Photoshop Cs6 Buy Windows 7 Cd Key Autodesk Maya 2012 Mac Cheap Windows 7 Home Premium Product Key Microsoft Office Access 2007 Oem Cheaper Adobe Elearning Suite 2 MacWe worked hard on the right caching strategy over months now. But there are still caches that do not get invalidated right or are cached too long and we still get complaints from our users. So we decided to integrate a feature that allows certain users to invalidate the cache on the server side. The first idea was to add a link to every page that will append a GET-parameter to the site and then avoid the cache.
Thanks to a bug ticket I remembered that certain browsers could force squid to reload the resources. The trick is that the HTTP/1.1-protocol has some features to control caching. If you press ctrl+F5 in your browser some of this features are triggered and sent over the wire in the http-request-header. I found a great article about headers in different browsers, unfortunately it’s not correct in every case.
Request Headers in PHP
So I had to find out what these browsers in fact are sending. Sure – you could find out with a sniffer, but as I needed this data in my script anyway I tried to get them from php. As long as your php installation does run as an apache module this is pretty easy: With apache_request_header() you get an array with all header information. I did add them to our debug window and I did get something like:
Trevi_Debug_Dump::dump(array(8), 'headers') (/home/xxx/sb2/www/bootstrap.php:73) array 'Accept' => string '*/*' (length=3) 'Accept-Language' => string 'de-ch' (length=5) 'Accept-Encoding' => string 'gzip, deflate' (length=13) 'User-Agent' => string 'Mozilla/4.0 ([...]; InfoPath.1)' (length=86) 'Host' => string 'ch.sb2.leo.dev.tilllate.com' (length=27) 'Connection' => string 'Keep-Alive' (length=10) 'Cache-Control' => string 'no-cache' (length=8) 'Cookie' => string '__utma=[...]' (length=769)
Browser Magic
So I tried this for different browsers. Unfortunately it’s specified nowhere what a browser has to send in which situation.
Internet Explorer 6 and 7 do both send only cache refresh hints on ctrl+F5. On ctrl+F5 they both send the header field ‘Cache-Control’ set to ‘no-cache’.
Firefox 3 do send the header field ‘Cache-Control’ with the value ‘max-age=0′ if the user press f5. If you press ctrl+f5 Firefox sends the ‘Cache-Control’ with ‘no-cache’ (hey it do the same as IE!) and send also a field ‘Pragma’ which is also set to ‘no-cache’.
Firefox 2 does send the header field ‘Cache-Control’ with the value ‘max-age=0′ if the user press f5. ctrl+f5 does not work.
Opera/9.62 does send ‘Cache-Control’ with the value ‘max-age=0′ after f5 and ctrl+f5 does not work.
Safari 3.1.2 behaves like Opera above.
Chrome does something quite different: ‘Cache-Control’ is always set to ‘max-age=0′, no matter if you press enter, f5 or ctrl+f5. Except if you start Chrome and enter the url and press enter.
Browser Wars
Somehow it does look like there is still war outside. The Browser War is not over yet! Nearly every browser seams to interpret the http standard a bit different. This makes implementing software for the web quite hard, Chrome does not help at all at this point.
As my cache-invalidation-implementation is implemented only for a small user base I will make it only work for IE and FF 3.

Surely Etags & Last-Modifieds are preferable to this, and allow the client browser to ask if its cached copy is still valid.
Comment by Ren — 14. November 2008 @ 17:57
Personally I simply notify users when some of their submitted content is not shown yet due to caching, I’ve yet to hear any complaints, same goes for downtime, so long as they know why things are happening the way they are they’re usually OK with it.
Feedback to your users can save you lots of complicated work.
Comment by Martin F — 14. November 2008 @ 19:19
I believe FF2 and FF3 also use Ctlr+Shift+r to bust the cache.
Comment by Micah — 15. November 2008 @ 00:53
For FireFox, you can also force a full refresh by holding down shift and clicking on the refresh button.
Comment by Bryan Migliorisi — 16. November 2008 @ 19:23
@Martin F.: I completly agree on this. But if you use Memcache for caching you have alot of different values and it’s hard to comunicate this to the user.
@Micah & Bryan: Yes, I tried it on FF3. Both methods force FF to send ‘Cache-Control’ and ‘Pragma’ with no-cache.
Comment by leo — 17. November 2008 @ 10:04
You can check your client headers at: view request headers
Comment by sergio — 17. November 2008 @ 18:08
cool how you censor your home directory but not the Host header
Comment by Jiayong Ou — 17. November 2008 @ 20:33
Man, we’re still dealing with browser wars…what a joke. I would be ok with it if everyone adhered to the W3C protocol and then added bells and whistles to make their browser ‘better’, but designing for multiple forms is crazy.
Comment by Acai — 26. November 2008 @ 09:41
[...] techblog.tilllate.com gab es vor kurzer Zeit einen recht interessanten Ansatz zur Cache-Kontrolle durch den User. Dieses ist eine deutsche Erklärung dazu, die noch einen kleinen Schritt weiter [...]
Pingback by Clientside Cache Control - Webboarder — 27. November 2008 @ 19:01
I personally find firefox to be the most effective website with the smallest cache. Also as stated before you can do a force full refresh by holding down shift and clicking refresh.
Comment by Eric Bence — 11. January 2009 @ 20:40
Cache in FF really sucks! Why the hell safari does so well?
Comment by Gomer — 2. April 2009 @ 22:25