Code Snippets

JSON correct http header

2011/02/21 | Comment?

As specified from the RFC4627 the correct header is application/json and not text/json.

In PHP you can use:


header('Content-type: application/json');

If you need not cache the output, a common problem with GET requests on IE, you can use these lines of code:

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');

RFC4627.

Share and Enjoy:
  • Tumblr
  • Twitter
  • FriendFeed
  • Digg
  • StumbleUpon
  • del.icio.us
  • Technorati
  • Sphinn
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • RSS
Tags: , , , ,

have your say

:

:


«
»