What are the differences between Cache-Control: public and Cache-Control: private?

Cache-Control: public indicates that the response can be cached by any cache, whether it's a shared cache or a private cache. On the other hand, Cache-Control: private specifies that the response is intended for a single user and should not be stored in shared caches. To set the Cache-Control header in PHP, you can use the header() function like this:

header('Cache-Control: public'); // for public caching
// OR
header('Cache-Control: private'); // for private caching