php为请求的图像设置标题

Simply,

if the url requested is that of an image, like myserverpath/image.jpg, then how can I set headers for this? Also, I have some custom logic before headers can be set. So, how can this be done?

Specifically:

I'm using picasso library to load images:

String url = myserverpath/image.jpg

Picasso.with(context)
                .load(url)
                .placeholder(R.drawable.ic_contact_picture)
                .error(R.drawable.ic_contact_picture)
                .into(imageView);

Gradle dependencies:

compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.+'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.+'

Picasso uses OkHttp (Http client) internally to take correct actions for headers like cache control etc.

Now, I want to set headers using php, like:

header('Cache-Control: public');
//check if page has changed. If not, send 304 and exit
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])==$lastModified || $etagHeader == $etagFile)
{
       header("HTTP/1.1 304 Not Modified");
       exit;
}

But since the url in picasso is a .jpg file and not .php file (where I can set headers), how can I set the headers?