Json header not working - php

I have a web service and a web interface for a registered user. this section allows the user to get their statistics (like stack overflow)

  • number of views
  • number of responses
  • number of posts
  • number of support tickets, etc ...

Now this tool I allow the user to retrieve their data in json format, my problem is that the sent header does not work for all 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 expiration and cache controls?

+6
source share
2 answers

The common MIME for json is application/json .

+9
source

You should use:

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

See also: What is the correct JSON content type?

+4
source

Source: https://habr.com/ru/post/904433/


All Articles