Erlang Mailing Lists

Author Message

<  Yaws mailing list  ~  Cache + YAWS file

Guest
Posted: Wed May 19, 2010 5:51 pm Reply with quote
Guest
erlyaws-list,

I have a yaws file which generates a page with almost static content
b/c it is created from the contents of an almost static table in a
database. This page will be requested very often by different clients,
so it makes good sense to cache this page. In production it is
reasonable to generate this page once-per-day. One way to accomplish
this is to put a proper Cache-Control HTTP header in the output and
then put a reverse-caching-proxy (squid) in front of yaws. However it
would be nice if yaws could do this automatically and didn't have to
introduce squid into the deployment procedures.

I tried using #gconf.max_size_cached_file,
#gconf.max_num_cached_bytes, #gconf.max_num_cached_files and setting
the Cache-Control header to see if yaws would just ``do it'', but it
appears not so. I checked yaws_server.erl, but was not able to quickly
discern if the output of a yaws file can be coerced into the cache.

So, can I persuade yaws to cache the output of a yaws file as-is,
preferably honoring the Cache-Control headers? If not, perhaps someone
can venture an opinion as to whether this would be reasonable to
implement? Otherwise, I will put up squid.

Brady

------------------------------------------------------------------------------

_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received from mailinglist
Guest
Posted: Wed May 19, 2010 6:53 pm Reply with quote
Guest
On 05/19/2010 07:49 PM, Brady McCary wrote:
> erlyaws-list,
>
> I have a yaws file which generates a page with almost static content
> b/c it is created from the contents of an almost static table in a
> database. This page will be requested very often by different clients,
> so it makes good sense to cache this page. In production it is
> reasonable to generate this page once-per-day. One way to accomplish
> this is to put a proper Cache-Control HTTP header in the output and
> then put a reverse-caching-proxy (squid) in front of yaws. However it
> would be nice if yaws could do this automatically and didn't have to
> introduce squid into the deployment procedures.
>
> I tried using #gconf.max_size_cached_file,
> #gconf.max_num_cached_bytes, #gconf.max_num_cached_files and setting
> the Cache-Control header to see if yaws would just ``do it'', but it
> appears not so. I checked yaws_server.erl, but was not able to quickly
> discern if the output of a yaws file can be coerced into the cache.
>
> So, can I persuade yaws to cache the output of a yaws file as-is,
> preferably honoring the Cache-Control headers? If not, perhaps someone
> can venture an opinion as to whether this would be reasonable to
> implement? Otherwise, I will put up squid.
>

First, Yaws never caches .yaws pages, all the cache control knobs are
for static files, i.e .gif/png files etc that can be shipped from memory
directly.
I think you should do two things,

1. Learn and use the HTTP headers properly here. I know I've had similar
situations before, but you shouldn't have to involve squid and caching, just
the client side caching. Don't remember exactly how to tune this, but I do
remember that it's possible .

2. Cache it in you app, in ram or on file. Super easy.


/klacke

------------------------------------------------------------------------------

_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received from mailinglist
Guest
Posted: Wed May 19, 2010 7:54 pm Reply with quote
Guest
2010/5/19 Claes Wikstrom <klacke@tail-f.com (klacke@tail-f.com)>
Quote:
On 05/19/2010 07:49 PM, Brady McCary wrote:
> erlyaws-list,
>
> I have a yaws file which generates a page with almost static content
> b/c it is created from the contents of an almost static table in a
> database. This page will be requested very often by different clients,
> so it makes good sense to cache this page. In production it is
> reasonable to generate this page once-per-day. One way to accomplish
> this is to put a proper Cache-Control HTTP header in the output and
> then put a reverse-caching-proxy (squid) in front of yaws. However it
> would be nice if yaws could do this automatically and didn't have to
> introduce squid into the deployment procedures.
>
> I tried using #gconf.max_size_cached_file,
> #gconf.max_num_cached_bytes, #gconf.max_num_cached_files and setting
> the Cache-Control header to see if yaws would just ``do it'', but it
> appears not so. I checked yaws_server.erl, but was not able to quickly
> discern if the output of a yaws file can be coerced into the cache.
>
> So, can I persuade yaws to cache the output of a yaws file as-is,
> preferably honoring the Cache-Control headers? If not, perhaps someone
> can venture an opinion as to whether this would be reasonable to
> implement? Otherwise, I will put up squid.
>


First, Yaws never caches .yaws pages, all the cache control knobs are
for static files, i.e .gif/png files etc that can be shipped from memory
directly.
I think you should do two things,

1. Learn and use the HTTP headers properly here. I know I've had similar
situations before, but you shouldn't have to involve squid and caching, just
the client side caching. Don't remember exactly how to tune this, but I do
remember that it's possible .

2. Cache it in you app, in ram or on file. Super easy.


/klacke


------------------------------------------------------------------------------

_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net (erlyaws-list@lists.sourceforge.net)
https://lists.sourceforge.net/lists/listinfo/erlyaws-list




Oh, that remembers me on an http header i read for a while.
Does yaws make use of the ETag http-header? http://en.wikipedia.org/wiki/HTTP_ETag
If not, this would be a big benefit for static datas



Post received from mailinglist
Guest
Posted: Wed May 19, 2010 10:39 pm Reply with quote
Guest
On 05/19/2010 09:53 PM, Daniel Fahlke wrote:
>
>
> Oh, that remembers me on an http header i read for a while.
> Does yaws make use of the ETag http-header?
> http://en.wikipedia.org/wiki/HTTP_ETag
> If not, this would be a big benefit for static datas
>
>

Yes, yaws sets ETag for static content, but your .yaws file
is not static.

/klacke

------------------------------------------------------------------------------

_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum