Hi,

I just upgraded the CDN module on D6 and suddenly the websites failed to respond. I tracked the issue down to the the new Far Future expiration feature which is active by default:

line 41 @ cdn.module

define('CDN_BASIC_FARFUTURE_DEFAULT', TRUE);

I didn't had the time to check this feature and how it can improve the performance in my websites, but this doesn't seem to be a standard feature on all CDNs, so I really think you should be more careful when upgrading the module.

For now, I've managed to work around the issue by changing the source code to:

define('CDN_BASIC_FARFUTURE_DEFAULT', FALSE);

... which is not a desirable solution at all.

Are you going to keep this as is? In that case where can I find some good documentation regarding the usage of this feature on a CDN server?

Thanks in advance,
Rolando

Comments

Wim Leers’s picture

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

This is not a feature that needs to be supported by CDNs: it's a matter of the site supporting it. You can find the documentation in the module, if you just enable the Advanced Help module.

Could you please provide more detailed information? "failed to respond" is definitely not enough information to track down this problem.

FWIW, this is running on both a D6 and a D7 site in production of mine, without problems. I wouldn't have released it otherwise. It should work just fine, which is why it's enabled by default. Let's fix this ASAP!

rolando.isidoro’s picture

Issue tags: +404, +nginx, +CDN, +far future

Hi Wim,

first, thanks for your quick reply. Second, I've looked into the module's Advanced Help info, but I'm still not sure what's the best way to workaround the problem I've experienced.

To give you some more insight on the issue here some additional info. I'm not using any commercial CDN solution, I've set up a origin pull local CDN solution based on nginx just to separate the HTTP requests and ease of the load on the main server.

After updating the module the websites didn't open, and all CDN requests where returning 404. For example the original CDN URL was something like:

http://cdn.example.com/sites/www.example.com/files/css/css_e26f771018dad4302bb944297ef2b2d8.css

after the update it became:

http://cdn.example.com/cdn/farfuture/mtime:1327487429/sites/www.example.com/files/css/css_e26f771018dad4302bb944297ef2b2d8.css

From the looks of it, I guess I have 2 options:

  1. Turn the CDN far future off;
  2. Change my nginx URL matching rules to work with these new URLs.

Do you see any other way to work around this?

Thanks again,
Rolando Isidoro

Wim Leers’s picture

Title: Far Future expiration setting active by default results in major errors » Far Future expiration + static file server
Version: 6.x-2.2 » 7.x-2.x-dev
Component: Origin Pull mode » Documentation
Category: bug » task

This is only a problem when enabling the Far Future expiration setting + a static file server. It works fine when used with a "regular" CDN.

You can solve this by rewriting /cdn/farfuture/*** URLs to ***. See the .htaccess at #1413156: .htaccess rules for Far Future expiration: make it possible to use the Far Future feature directly in Apache, avoiding PHP for an example. Pleas let me know your nginx config so I can document this.

rolando.isidoro’s picture

Hi Wim,

the solution you mention, to add some additional rewrite rules will only increase the type of URLs the nginx server can handle, but won't provide any significant improvement.

Regarding the nginx config, there's not much to it, we're using a shared FS mount for both the main server (Apache) and the CDN (nginx), so basically we only have the following to guaranty that the ImageCache files get created upon the 1st request:

# www.sub-domain.domain.com
location ~ ^/sites/ www.sub-domain.domain.com {
        set $domain 'www.sub-domain.domain.com';
        if (!-e $request_filename) {
                rewrite ^(.*)$ http://$domain/$1 last;
                break;
        }
}

# Fallback to default website if none of the other appy
if (!-e $request_filename) {
        rewrite ^(.*)$ http://www.domain.com$1 last;
        break;
}

Nonetheless, keeping the Far Future module setting turned off by default still seems the easiest and most compatible solution.

Best regards,
Rolando Isidoro

Wim Leers’s picture

Title: Far Future expiration + static file server » nginx config generator for Far Future expiration

I was actually asking for an nginx config similar to #1413156: .htaccess rules for Far Future expiration: make it possible to use the Far Future feature directly in Apache, avoiding PHP. That *should* solve the problem at hand.

rolando.isidoro’s picture

Hi Wim,

I understand what you're asking, but what I don't get is why this new feature is active by default. I find it even harder to conceive why can't I deactivate it, even if I explicitly uncheck the option in the configuration form.

Simply put, you added the far future option and there's no way someone using your module to not use it, right?

Best regards,
Rolando

Wim Leers’s picture

There's a simple checkbox to disable on the "Details" page…

rolando.isidoro’s picture

Version: 7.x-2.x-dev » 6.x-2.2

Wim,

on the previous version of the module, 6.x-2.2, the "cdn_farfuture_status" variable wasn't written with value 0 on the DB when I saved the details configuration form, resulting on the behavior to fallback to the value set on the constant CDN_BASIC_FARFUTURE_DEFAULT. In the meantime I've update to 2.3 and now it does, which means that I'm now able to deactivate it.

But check my case, I have 20+ sites, all using the CDN module. At this point I would have to go through each site and save the CDN details settings form with the the Far Future expiration unchecked. Does it seem reasonable?

Best regards,
Rolando

Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Active

#8: The Far Future feature has not been active by default since version 2.4.

Marked #1595498: Nginx config for sub-domains as a duplicate of this one.

Note that I can't provide this config file, because I don't use nor have any experience with nginx. So I hope the community will contribute it.

Wim Leers’s picture

Version: 6.x-2.2 » 7.x-2.x-dev
jtbayly’s picture

We're getting somewhere on this over at #1728616: Support CDN module, for all who are interested.

It's specific to the Omega8 setup, but it shouldn't be hard for somebody with Nginx experience to modify it.

-Joseph

Wim Leers’s picture

That's AWESOME! :)

Wim Leers’s picture

Component: Documentation » Origin Pull mode — Far Future expiration
Wim Leers’s picture

Wim Leers’s picture

Title: nginx config generator for Far Future expiration » nginx config for Far Future expiration: use the Far Future feature directly in nginx, avoiding PHP

Marked #2331829: Add Nginx Configuration example in README.txt as a duplicate.

Note that #1413156: .htaccess rules for Far Future expiration: make it possible to use the Far Future feature directly in Apache, avoiding PHP already contained partial nginx examples, but they were less well tested, which is why I didn't commit them there yet.

Wim Leers’s picture

Assigned: Wim Leers » Unassigned
Wim Leers’s picture

Status: Active » Needs review
Issue tags: -404, -CDN, -far future

From #1413156-23: .htaccess rules for Far Future expiration: make it possible to use the Far Future feature directly in Apache, avoiding PHP, by @omega8cc:
:

###
### CDN Far Future expiration support.
###
location ^~ /cdn/farfuture/ {
  tcp_nodelay   off;
  access_log    off;
  log_not_found off;
  etag          off;
  gzip_http_version 1.0;
  if_modified_since exact;
  location ~* ^/cdn/farfuture/.+\.(?:css|js|jpe?g|gif|png|ico|bmp|svg|swf|pdf|docx?|xlsx?|pptx?|tiff?|txt|rtf|class|otf|ttf|woff|eot|less)$ {
    expires max;
    add_header X-Header "CDN Far Future Generator 1.0";
    add_header Cache-Control "no-transform, public";
    add_header Last-Modified "Wed, 20 Jan 1988 04:20:42 GMT";
    rewrite ^/cdn/farfuture/[^/]+/[^/]+/(.+)$ /$1 break;
    try_files $uri @nobots;
  }
  location ~* ^/cdn/farfuture/ {
    expires epoch;
    add_header X-Header "CDN Far Future Generator 1.1";
    add_header Cache-Control "private, must-revalidate, proxy-revalidate";
    rewrite ^/cdn/farfuture/[^/]+/[^/]+/(.+)$ /$1 break;
    try_files $uri @nobots;
  }
  try_files $uri @nobots;
}

Would be great if nginx users could test that.

Wim Leers’s picture

Priority: Major » Minor
Status: Needs review » Closed (outdated)

Clearly interest in this is very low. Since @jtbayly in #11 back in 2012, nobody has commented on this.

glynster’s picture

Component: Origin Pull mode — Far Future expiration » Code

@Wim Leers we just added this to a production site and works like a charm. We were having issues with background images in CSS files and fonts. With your Nginx snippet all works well. Thanks so much!