Archive for March, 2009
Displaying custom error message with the right HTTP response codes
Posted by primeminister | Filed under Cake-Toppings
I’m building an RESTful API with CakePHP now. That is great stuff. Very easy and quick for the basics. Some more info on how to in the book and here.
But I wanted a custom XML error message with the right HTTP respond code like the Twitter API does. I knew it could be done with overwriting the AppError class and make my own custom method.
This is how I did it: (more…)
Cache duration and configuration tips
Posted by primeminister | Filed under Cake-Toppings
As you know you can cache several elements in you application. When I wrote a value to the cache I did it by setting the duration in the third parameter of write:
Cache::write('cache_key', 'value to cache',array(
'config'=>'default',
'duration'=>'+1 day')
);
But today I learned a lesson from Mark Story that this was a bug and it is fixed and doens’t work anymore. It is ignored.
So how do I set the duration before read/write for specific data in my code? (more…)