You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by John Kew <jo...@socrata.com> on 2013/06/18 06:49:10 UTC

Supporting Cache-Control headers

Azure supports setting cache control headers on blobs through the
"x-ms-blob-cache-control" header on a blob put; but there does not seem to
be an easy way to set this through azure.

Adding:
   var meta = new util.HashMap[String, String]
   meta.put("x-ms-blob-cache-control", "must-revalidate")
   var payload =
context.getAsyncBlobStore.blobBuilder(test_key).userMetadata(meta)...

Results in the header being prefixed with "x-ms-meta-" because the
AzureBlobApiMetadata class sets this as the PROPERTY_USER_METADATA_PREFIX
property; which is bound to the request deep down in the bowels of jclouds.

For user meta-data this is the correct behavior; as described in
   http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx

But there does not seem to be an easy way to work around the prefix binding
for things which sort-of fall into this grey area of content/user data. A
work-around I'm using is to set the override properties, as in:

    val prop = BaseRestApiMetadata.defaultProperties()
    prop.put(BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX, "")
    val context =
ContextBuilder.newBuilder("azureblob").overrides(prop).credentials("jkew","a
secret key")
      .modules(modules).buildView(classOf[BlobStoreContext])

That's OK for some things; but we need to do some sweet cross-cloud
blobbery, and it would be great if there were some general way of setting
the desired Cache-Control headers for CDNs, or a convenient way of
by-passing the prefix bindings somehow for some properties.

Should I file a feature request; or is this just not a general enough
feature to be exposed at a more general level?

-John Kew

Re: Supporting Cache-Control headers

Posted by Andrew Phillips <an...@apache.org>.
> Would the *content* metadata of the payload be a better match for this?
> I haven't tried to see if this particular property can actually be set
> for Azure in this way - just trying to find the correct place for it,
> first...

Having just written that, I'd suspect the answer to my own question is  
"no", since cache control is really an attribute of the *blob*  
irrespective of its content?

In that case, it would seem - in the case of Azure at least - that our  
assumption that all user metadata has the same prefix is simply  
incorrect, in which case a bug or feature request would seem to be in  
order...

ap

Re: Supporting Cache-Control headers

Posted by Andrew Phillips <an...@apache.org>.
> For user meta-data this is the correct behavior; as described in
>    http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
>
> But there does not seem to be an easy way to work around the prefix binding
> for things which sort-of fall into this grey area of content/user data.

Would the *content* metadata of the payload be a better match for  
this? I haven't tried to see if this particular property can actually  
be set for Azure in this way - just trying to find the correct place  
for it, first...

https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/io/Payload.java#L51

Regards

ap