librelist archives

« back to archive

How Photon handle HTTP : 304 Not Modified

How Photon handle HTTP : 304 Not Modified

From:
William Martin
Date:
2011-03-16 @ 21:34
Hi,

Just another question, my test site have some media (css & image).
I serve it with :

             array('regex' => '#^/media/(.*)$#',
                   'view' => array('\photon\views\AssetDir', 'serve'),
                   'name' => 'website_assets',
                   'params' => __DIR__ . '/media',
                   ),

I always have HTTP 200 Ok with file transfert, but never 304 not modified.
This is a static part of website, so it's will be interesting to use
the browser cache.

William

-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] How Photon handle HTTP : 304 Not Modified

From:
Loic d'Anterroches
Date:
2011-03-17 @ 17:10
Hello,

> Just another question, my test site have some media (css & image).
> I serve it with :
> 
>              array('regex' => '#^/media/(.*)$#',
>                    'view' => array('\photon\views\AssetDir', 'serve'),
>                    'name' => 'website_assets',
>                    'params' => __DIR__ . '/media',
>                    ),
> 
> I always have HTTP 200 Ok with file transfert, but never 304 not modified.
> This is a static part of website, so it's will be interesting to use
> the browser cache.

As you may have seen, the AssetDir::serve view is very simple and does
not handle the cache headers. This is a know issue.

loïc

--
Indefero - Project management and code hosting - http://www.indefero.net
Photon - High Performance PHP Framework - http://photon-project.com
Céondo Ltd - Web + Science = Fun - http://www.ceondo.com

Re: [photon.users] How Photon handle HTTP : 304 Not Modified

From:
William Martin
Date:
2011-03-18 @ 08:04
Thanks for the reply,

I will try to make a patch next week.

William

On Thu, Mar 17, 2011 at 6:10 PM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Hello,
>
>> Just another question, my test site have some media (css & image).
>> I serve it with :
>>
>>              array('regex' => '#^/media/(.*)$#',
>>                    'view' => array('\photon\views\AssetDir', 'serve'),
>>                    'name' => 'website_assets',
>>                    'params' => __DIR__ . '/media',
>>                    ),
>>
>> I always have HTTP 200 Ok with file transfert, but never 304 not modified.
>> This is a static part of website, so it's will be interesting to use
>> the browser cache.
>
> As you may have seen, the AssetDir::serve view is very simple and does
> not handle the cache headers. This is a know issue.
>
> loïc
>
> --
> Indefero - Project management and code hosting - http://www.indefero.net
> Photon - High Performance PHP Framework - http://photon-project.com
> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com
>



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] How Photon handle HTTP : 304 Not Modified

From:
Mehdi Kabab
Date:
2011-03-18 @ 12:34
Hello William,

You can also delegate the static resources to mongrel2:

hosts = [
    Host(
        name="localhost",
        routes={
            '/media/': Dir(base="your/real/www/media/",
index_file="index.html", default_ctype="text/plain"),
        }
    )
]

Mongrel2 serve files with support for 304 and ETag.

-- 
Mehdi Kabab
Développeur Web / Auteur

CV : http://mehdi.kabab.name/
Livre : http://gimp4you.eu.org/livre/
Code : http://pioupioum.fr/
Twitter: http://twitter.com/piouPiouM

2011/3/16 William MARTIN <wysman@gmail.com>

> Hi,
>
> Just another question, my test site have some media (css & image).
> I serve it with :
>
>             array('regex' => '#^/media/(.*)$#',
>                   'view' => array('\photon\views\AssetDir', 'serve'),
>                   'name' => 'website_assets',
>                   'params' => __DIR__ . '/media',
>                   ),
>
> I always have HTTP 200 Ok with file transfert, but never 304 not modified.
> This is a static part of website, so it's will be interesting to use
> the browser cache.
>
> William
>
> --
> ---------------------------------------------------------
> William MARTIN
> wysman @NoSpAm@ gmail @DoT@ com
>