When I enable the CDN module a few (3) background images in the aggregated css file have their url changed from sites/default/imagename.jpg?1361481214 to imagename.jpg%3f1361481214

It turns out that the ?1361481214 was being added by compass when it compiles the css. I've disabled the appending of the timestamp with asset_cache_buster :none in my config.rb.

I believe the problem is in cdn.basic.css.inc but once I realized I could change the compass compile settings I did that.

This problem doesn't happen with CDN disabled and core css/js aggregation enabled.

Comments

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Status: Active » Postponed (maintainer needs more info)

Does this occur with or without Far Future expiration, or both?

greggles’s picture

Status: Postponed (maintainer needs more info) » Active

Both.

Wim Leers’s picture

Title: 404 when background images querystring gets changed from imagename.jpg?1361481214 to imagename.jpg%3f1361481214 » CSS aggregation override breaks querystrings of referenced files
Category: support » bug

Are you 100% certain that you're on version 2.6? I made it possible to have query strings there, to be compatible with Drupal >=7.20.

However, upon looking at that diff again (http://drupalcode.org/project/cdn.git/commitdiff/c9b98bf), I see that I only did this for the HTML parsing case. That was all that was necessary for Drupal >=7.20 compatibility.

What you're encountering here is a different case: this is not in HTML handling, but in the CSS aggregation override.

So: it *must* be a bug. cdn_file_url_alter() assumes (like Drupal core) that files passed to file_create_url() don't have query strings. That assumption is no longer true in this case.

greggles’s picture

Right, that was roughly the conclusion I came to as well: that it's being filtered (check_plain?) by some code that assumes there is no querystring.

dsbrianwebster’s picture

I'm having this problem as well.

For me though it only occurs with Far Future expiration.

It happens on any file that has a query or fragment. This includes files generated by sass/compass as well as, for example font files such as:

fontawesome-webfont.eot?v=3.2.1

I see this issue has been quiet for a while. This impacts a pending site launch. What did everyone do to get around this?

greggles’s picture

We just explicitly removed the querystrings from our sass/css files. This "fixes" the problem but means that we can't use querystrings to burst caches when a new version is released.

dsbrianwebster’s picture

Thanks for the quick feedback greggles.

What's the feeling on changing line 155 in cdn.basic.css.inc from

return 'url(' . file_create_url($path) . ')';

to

return 'url(' . urldecode(file_create_url($path)) . ')';

This gets things working for me and allows me to keep the query strings on all my images, font files, etc. What is the downside of not encoding these file urls? That is definitely where the problem is occurring. Is encoding really necessary here?

One thing to add though. While this gets files with query strings to load, the url returned is still pointing to the Drupal file system. Shouldn't this be pointing to the CDN as it does when Far Future expiration is turned off?

greggles’s picture

I wonder if the problem is that the there's a url( wrapped around the file_create_url when file_create_url already returns a full url. It seems like it's essentially running url on a string twice which would definitely be a problem.

greggles’s picture

Status: Active » Closed (duplicate)

I believe this is a duplicate of #1514182: IE @font-face CSS hack URL broken by CDN module's overridden CSS aggregation which has some patches and more discussion.