6

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?

3
  • 2
    The commonly accepted MIME for json is application/json. Commented Dec 24, 2011 at 14:41
  • thanks @TomvanderWoerdt, can you put this as your answer so i can accept it? Commented Dec 24, 2011 at 14:42
  • JSON is typically not a format that works in web browsers, unlike HTML or XML. If you use JSON, then you'd expect a JSON parser to read it, not a browser. Commented Dec 24, 2011 at 14:43

2 Answers 2

9

The commonly accepted MIME for json is application/json.

Sign up to request clarification or add additional context in comments.

Comments

4

You should use:

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

See also: What is the correct JSON content type?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.