Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR] Phalcon\Http\Response can support send_file and getheader optimization? #545

Closed
dreamsxin opened this issue Apr 13, 2013 · 1 comment
Labels
new feature request Planned Feature or New Feature Request
Milestone

Comments

@dreamsxin
Copy link
Contributor

I display image, now:

            $filename = 'avatar.png';

            $etag = md5_file($filename);
            $this->response->setHeader('etag', $etag);
            $this->response->setHeader('Cache-Control', 'must-revalidate');

            $retag = $this->request->getHeader('HTTP_IF_NONE_MATCH');

            if ($retag AND $retag == $etag)
            {
                $this->response->setStatusCode(304, 'Not Modified');
                $this->response->send();

            } else {
                $this->response->setHeader('cache-control', 'max-age=3600');            
                $this->response->send();

                http_send_content_type("image/jpeg");
                http_send_file($filename);
            }

if has send_file:

            $filename = 'avatar.png';

            $etag = md5_file($filename);
            $this->response->setHeader('Etag', $etag);
            $this->response->setHeader('Cache-Control', 'must-revalidate');

            $retag = $this->request->getHeader('if-none-match');

            if ($retag AND $retag == $etag)
            {
                $this->response->setStatusCode(304, 'Not Modified');
                $this->response->send();

            } else {
                $this->response->setHeader('Cache-Control', 'max-age=3600');            
                $this->response->send_file($filename);
                $this->response->send();
            }
@phalcon
Copy link
Collaborator

phalcon commented May 22, 2013

This is already implemented but needs to be documented

@phalcon phalcon closed this as completed Jun 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature request Planned Feature or New Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant