Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

json header does not work - php

i have a webservice and a web interface for registered user. this section allow the user to get their statistics (similar to stack overflow)

  • number of views
  • number of answers
  • number of post
  • number of support ticket etc...

now this tool i have allow the user to retreive their data in a json format, my problem is the header sent is not working for all the browsers

i have:

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

should i remove the expires and cache control?

like image 318
Joanna Lancaster Avatar asked Dec 24 '11 14:12

Joanna Lancaster


2 Answers

The commonly accepted MIME for json is application/json.

like image 135
Tom van der Woerdt Avatar answered Nov 03 '22 12:11

Tom van der Woerdt


You should use:

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

See also: What is the correct JSON content type?

like image 24
Rob W Avatar answered Nov 03 '22 12:11

Rob W