I encountered a problem tryng to use this module with the cdn module that is needed to load our pages faster. The cdn can't fetch url and the result is that the images are all missing.

Any suggestion on how to configure ais with cdn support?

Comments

spotzero’s picture

Unfortunately, you probably can't use AIS with a CND out of the box.

This is because:

No AIS Cookie:
/image-url => returns the image (hosted by the CND).

With AIS Cookie:
/image-url => redirect to /resized-image-url (needs to be hosted by Drupal)

Unless your CND can be configured to be cookie aware, this will be problematic since this module essentially make the url to the image magical (sometimes returning an image, and sometimes redirecting to a more appropriate image, depending on a cookie).

However, you could probably solve this by making all images redirect.

You'd need to update the htaccess rules to do something like the following:

# AIS: Adaptive Image Style
  RewriteBase /
  RewriteCond %{REQUEST_URI} ^(.+)/files/styles/adaptive/(.+)$
  RewriteCond %{REQUEST_URI} !/modules/image/sample.png
  RewriteCond %{HTTP_COOKIE} ais=([a-z0-9_-]+)
  RewriteRule ^(.+)/files/styles/adaptive/(.+)$ http://CND/files/styles/%1/$2 [R=302,L]

  RewriteBase /
  RewriteCond %{REQUEST_URI} ^(.+)/files/styles/adaptive/(.+)$
  RewriteRule ^(.+)/files/styles/adaptive/(.+)$ http://CND/files/styles/adaptive/$2 [R=302,L]

This means all of your adaptive images must go to Drupal (so Drupal can decide whether or not to adapt them), but all of the actual image files will be hosted by the CND.

spotzero’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)