Can Google CDNs cache dynamically generated files ?

84 views
Skip to first unread message

Francois Masurel

unread,
Sep 13, 2010, 12:25:28 PM9/13/10
to Google App Engine
Let me explain :

I have potentially too many (> 3000) GWT generated files in my java
application. I've already packed all my java classes in a jar.

So I made a zip of all these files and implemented a servlet to serve
them dynamically.

The servlet url-pattern matches an include path defined in my
appengine-web.xml static-files block.

The question is : will the files served by my servlet be cached on
Google CDNs as supposed in this thread :

http://groups.google.com/group/google-appengine/browse_thread/thread/8b8a37a1d9e6a8a/d44460ec9809d1a3

It doesn't seem to be the case as each time I purge my browser cache,
the files are served again from my servlet.

Thanx for your help.

Francois

Robert Kluin

unread,
Sep 13, 2010, 2:43:35 PM9/13/10
to google-a...@googlegroups.com
If you are dynamically serving the files they should not be cached.


Robert

> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>

Francois MASUREL

unread,
Sep 13, 2010, 3:32:59 PM9/13/10
to google-a...@googlegroups.com

They are generated once for all or are served straight from a zip file.

Robert Kluin

unread,
Sep 13, 2010, 3:57:35 PM9/13/10
to google-a...@googlegroups.com
I think static files are handled separately from dynamic handlers, or
"servlets." I believe static content gets uploaded to something
Google's front-end servers directly accesses. If you are using a
dynamic handler to serve files out of a zip file requests will go to
your servlet, not get directly served by the front-end. At least that
is my understanding.

Is that what you are asking about?

Robert

Peter Liu

unread,
Sep 13, 2010, 4:00:26 PM9/13/10
to Google App Engine
From my experience, dynamic content is also cached if you set the
cache control headers.

On Sep 13, 9:25 am, Francois Masurel <fm2...@mably.com> wrote:
> Let me explain :
>
> I have potentially too many (> 3000) GWT generated files in my java
> application.  I've already packed all my java classes in a jar.
>
> So I made a zip of all these files and implemented a servlet to serve
> them dynamically.
>
> The servlet url-pattern matches an include path defined in my
> appengine-web.xml static-files block.
>
> The question is : will the files served by my servlet be cached on
> Google CDNs as supposed in this thread :
>
> http://groups.google.com/group/google-appengine/browse_thread/thread/...

Francois Masurel

unread,
Sep 13, 2010, 4:44:41 PM9/13/10
to Google App Engine
@Robert : yep, that's what I meant

@Peter : can someone at Google confirms that putting the right cache
controls headers (to be determined) servlet generated content can be
cached in Google CDNs ?

Thanx everybody for your answers.

Andrius A

unread,
Sep 14, 2010, 5:10:26 AM9/14/10
to google-a...@googlegroups.com
it wont be cached in CDN, but if you specify the correct http headers it will be cached by the browser. check:
http://code.google.com/appengine/docs/python/config/appconfig.html#Static_File_Handlers

Francois Masurel

unread,
Sep 14, 2010, 9:49:50 AM9/14/10
to Google App Engine
For the moment, I'll use memcache on the server side and cache control
headers on the client side.

On Sep 14, 11:10 am, Andrius A <andriu...@gmail.com> wrote:
> it wont be cached in CDN, but if you specify the correct http headers it
> will be cached by the browser. check:http://code.google.com/appengine/docs/python/config/appconfig.html#St...
> > google-appengi...@googlegroups.com<google-appengine%2Bunsubscrib e...@googlegroups.com>
> > .

Jason C

unread,
Sep 14, 2010, 1:28:33 PM9/14/10
to Google App Engine

Cache-Control: public, max-age=[seconds as an integer]

Should do the trick. "Public" is important otherwise downstream caches
(i.e., the Google CDN) won't hold the content (e.g., "private" will be
end-browser cache only).

If you want some good 304 revalidation, also use Last-Modified or
ETag. I think the G CDN supports this.

j

Francois Masurel

unread,
Sep 14, 2010, 3:19:09 PM9/14/10
to Google App Engine
Hi Jason, thanx for your answer.

Do you really mean that putting the right cache-control headers in my
content will allow it to be cached by Google CDNs ?

That would be great. I'll make a test as soon as possible.

Francois Masurel

unread,
Sep 14, 2010, 3:44:49 PM9/14/10
to Google App Engine
Yes, it works ! Thanx everybody.

I just added the "Cache-Control:public" header to my content. I
cleared my browser cache. After refreshing the page I don't see any
log coming from my ZipServingServlet. Cool.

BTW if you don't add the max-age info to your Cache-Control header,
Google sets it by default to 600 (10 minutes).

Robert Kluin

unread,
Sep 14, 2010, 3:48:04 PM9/14/10
to google-a...@googlegroups.com
Interesting. Thanks for the info.

> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.

Stephen

unread,
Sep 14, 2010, 3:47:53 PM9/14/10
to Google App Engine


On Sep 13, 5:25 pm, Francois Masurel <fm2...@mably.com> wrote:
> Let me explain :
>
> I have potentially too many (> 3000) GWT generated files in my java
> application.  I've already packed all my java classes in a jar.
>
> So I made a zip of all these files and implemented a servlet to serve
> them dynamically.
>
> The servlet url-pattern matches an include path defined in my
> appengine-web.xml static-files block.
>
> The question is : will the files served by my servlet be cached on
> Google CDNs as supposed in this thread :
>
> http://groups.google.com/group/google-appengine/browse_thread/thread/...
>
> It doesn't seem to be the case as each time I purge my browser cache,
> the files are served again from my servlet.


http://code.google.com/p/googleappengine/issues/detail?id=2258

Francois MASUREL

unread,
Sep 14, 2010, 3:57:54 PM9/14/10
to google-a...@googlegroups.com

Ikai Lan (Google)

unread,
Sep 14, 2010, 4:12:12 PM9/14/10
to google-a...@googlegroups.com
I wouldn't call it a CDN, but the caching infrastructure at Google may hold on to static assets with the correct headers set. One of the key benefits here is that you won't be charged CPU time for serving the asset, though bandwidth charges will still be applied. This is only a best effort caching and is not guaranteed, so in the worst case scenario the caching infrastructure will not hold on to your data and the requests will still be routed to your application instances. 

Francois MASUREL

unread,
Sep 14, 2010, 4:17:00 PM9/14/10
to google-a...@googlegroups.com
Thanx Ikai, that was the final answer we were waiting for.

We now have a good solution for serving more than 3000 GWT generated files efficiently :-)

François

Francois Masurel

unread,
Sep 15, 2010, 5:51:05 PM9/15/10
to Google App Engine
Sorry guys. But it doesn't seem to work in fact. Shit.

My static files were certainly kept in Google CDNs even after having
removed them from my web app.

Has anybody succeeded ?

On 14 sep, 22:17, Francois MASUREL <masu...@mably.com> wrote:
> Thanx Ikai, that was the final answer we were waiting for.
>
> We now have a good solution for serving more than 3000 GWT generated files
> efficiently :-)
>
> François
>
> On Tue, Sep 14, 2010 at 22:12, Ikai Lan (Google)
> <ikai.l+gro...@google.com<ikai.l%2Bgro...@google.com>
>
> > wrote:
> > I wouldn't call it a CDN, but the caching infrastructure at Google may hold
> > on to static assets with the correct headers set. One of the key benefits
> > here is that you won't be charged CPU time for serving the asset, though
> > bandwidth charges will still be applied. This is only a best effort caching
> > and is not guaranteed, so in the worst case scenario the caching
> > infrastructure will not hold on to your data and the requests will still be
> > routed to your application instances.
>
> > On Tue, Sep 14, 2010 at 12:57 PM, Francois MASUREL <masu...@mably.com>wrote:
>
> >> Full answer there :
>
> >>http://www.kyle-jensen.com/proxy-caching-on-google-appengine
>
> >> On Tue, Sep 14, 2010 at 21:47, Stephen <sdea...@gmail.com> wrote:
>
> >>> On Sep 13, 5:25 pm, Francois Masurel <fm2...@mably.com> wrote:
> >>> > Let me explain :
>
> >>> > I have potentially too many (> 3000) GWT generated files in my java
> >>> > application.  I've already packed all my java classes in a jar.
>
> >>> > So I made a zip of all these files and implemented a servlet to serve
> >>> > them dynamically.
>
> >>> > The servlet url-pattern matches an include path defined in my
> >>> > appengine-web.xml static-files block.
>
> >>> > The question is : will the files served by my servlet be cached on
> >>> > Google CDNs as supposed in this thread :
>
> >>> >http://groups.google.com/group/google-appengine/browse_thread/thread/.
> >>> ..
>
> >>> > It doesn't seem to be the case as each time I purge my browser cache,
> >>> > the files are served again from my servlet.
>
> >>>http://code.google.com/p/googleappengine/issues/detail?id=2258
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Google App Engine" group.
> >>> To post to this group, send email to google-a...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> google-appengi...@googlegroups.com<google-appengine%2Bunsu...@googlegroups.com>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/google-appengine?hl=en.
>
> >>  --
> >> You received this message because you are subscribed to the Google Groups
> >> "Google App Engine" group.
> >> To post to this group, send email to google-a...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> google-appengi...@googlegroups.com<google-appengine%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-appengine?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine" group.
> > To post to this group, send email to google-a...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengi...@googlegroups.com<google-appengine%2Bunsu...@googlegroups.com>
> > .

Francois Masurel

unread,
Sep 15, 2010, 6:05:32 PM9/15/10
to Google App Engine
Geez, it seems to be a Java only problem :

http://code.google.com/p/googleappengine/issues/detail?id=2070
Reply all
Reply to author
Forward
0 new messages