ImageCache module generates preset images on the fly.

If I enabled Parallel modules with existing ImageCache images, all works correctly.

But if I upload new image, call from the image URL transformed by Parallel module doesn't allow ImageCache module to operates and generates preset image.

ImacheCache preset images are only generated if called with native URL and not transformed one generates by Parallel module.

Comments

mikeytown2’s picture

Category: bug » support

Depends on how your setup. I use parallel with imagecache. How are you using parallel?

srobert72’s picture

I use for CSS, JS and images files.
As I said, it works on all already generated images. But not on new ones.

I use Parallel to deliver images from another domain with no cookies.

To generate new ImageCache preset mages I must call their URL on primary domain once and then after I can use their URL on cookieless domain.

mikeytown2’s picture

Title: Incompatibility with ImageCache » Incompatibility with ImageCache if using a different server to serve images

You should be able to run PHP on the other domains. This is actually a problem for SEO if not setup correctly
http://drupal.org/node/597178#comment-2735418

Are you using something other then apache to serve files on these other domains? You can use this patch for image cache which will generate the images on node creation
http://drupal.org/node/374202#comment-2799612 - Use it with the rules module.

srobert72’s picture

I would prefer Apache solution. But I'm a little bit surprise with 301 redirect.
If I configured second domain to deliver cookieless images, it's not to permanently redirect them back to original domain. In this case I could just disable Parallel no ?

Second domain should redirect to original one just at first time, if image doesn't exist.
All other requests can be sent to second cookieless domain.

mikeytown2’s picture

htaccess solution sounds interesting... question: are you using the same htaccess file for the main domain as well as the cookie-less domain?

mikeytown2’s picture

Based off of my SEO work I think this can easily be done... Untested ATM & should work with/without Drupal's htaccess rules.

  #Parallel Redirect - Redirect back to main site if file not found
  RewriteCond %{REQUEST_URI} (^/(.*)(.js|.css)) [NC,OR]
  RewriteCond %{HTTP_ACCEPT} (.*image.*|.*css.*|.*javascript.*) [NC]
  RewriteCond %{HTTP_HOST} ^(cdn1.example.com|cdn2.example.com|cdn3.example.com)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=307]

307 is a temporary redirect

mikeytown2’s picture

Status: Active » Needs review
srobert72’s picture

I use different htaccess for original (Drupal) domain and cookieless one.

Cookieless one only delivers images, CSS and JS generated by Drupal but it uses no PHP.
Cookieless domain only uses those Drupal directories :
/misc
/modules
/sites
/themes

Cookieless domain is on same Apache server and uses symbolic links for those directories to point to Drupal.
No need to copy files, they can be used when generated.

I will test your solution in cookieless htaccess and will tell result.
Thank you.

srobert72’s picture

#6
Those htaccess rules don't work, I have 404 error.

@mikeytown2
Is it working for you ?

mikeytown2’s picture

Since your using a different htaccess file for your cookieless domain, try this. This will break clean urls on a normal Drupal box, but should work in your case since it's a different htaccess file.

  #Parallel Redirect - Redirect back to main site if file not found
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=307]
srobert72’s picture

Maybe it's evident, but should be precised for everyone (I forgot it).
Those rules must be included with RewriteEngine on else it doesn't work.

This code is OK in my case :
Main Drupal site : www.example.com
Cookieless domain (to deliver images) : cdn3.cookielessexample.com

EDIT cdn3.cookielessexample.com/.htaccess :

<IfModule mod_rewrite.c>
  RewriteEngine on

  #Parallel Redirect - Redirect back to main site if file not found
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=307]

</IfModule>

First call, request is redirected (status=307) to Drupal main site so that imagecache can generate image.
Other calls (status=200) and no more redirect.

I think it's a good solution.
No intrusion code in other modules or other sites configurations.
We have just to edit .htaccess for cookieless domain.

Thank you very much @ mikeytown2 !!

mikeytown2’s picture

Would you mind testing the first set of rules I gave you with RewriteEngine on in place? Still curious about those, since those will not interfere with drupal's htaccess rules. Thanks for seeing that and fixing it on your own :)

srobert72’s picture

OK I will test it.

Just a precision, we can't use same domain for cookieless images.
Subdomain "cdn3" keeps cookies from main domain "example.com".

To configure cookieless you MUST use another domain, with "cdn3" subdomain name if you want (or any other subdomain name as you like). You must have TWO different domains.

Without that you lost all benefit from using Parallel module as it doesn't change nothing from using main Drupal URLs.

srobert72’s picture

Your first set of rules works. But I would rewrite it as follows:

Main Drupal site : www.example.com
Cookieless domain (to deliver images) : cdn3.cookielessexample.com
EDIT cdn3.cookielessexample.com/.htaccess :

  #Parallel Redirect - Redirect back to main site if file not found
  RewriteCond %{REQUEST_URI} (^/(.*)(.js|.css)) [NC,OR]
  RewriteCond %{HTTP_ACCEPT} (.*image.*|.*css.*|.*javascript.*) [NC]
  RewriteCond %{HTTP_HOST} ^(cdn1.cookielessexample.com|cdn2.example.com|cdn3.cookielessexample.com)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=307]

And in my opinion, second light set of rules is sufficient.
JS and CSS files aren't gererated on file request. They are generated and their URL are wrote in source code on page request. So requesting them from Parallel always work.
ImageCache is another workflow. Images are generated on file request. Requesting them from Parallel cookieless domain doesn't work because PHP isn't called and URL isn't intercepted by ImageCache.

So in my opinion best solution is :
Main Drupal site : www.example.com
Cookieless domain (to deliver images) : cdn3.cookielessexample.com
EDIT cdn3.cookielessexample.com/.htaccess :

<IfModule mod_rewrite.c>
  RewriteEngine on

  #Parallel Redirect - Redirect back to main site if file not found
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=307]

</IfModule>
mikeytown2’s picture

Status: Needs review » Reviewed & tested by the community
jcisio’s picture

Incorrect ;) By default Drupal cookie remove one level, that mean cdn.example.com and www.example.com has the same cookie, but s1.cdn.example.com and www.example.com don't.

My other solution for the redirect, not using RewriteEngine (so that it's easier to modify to use with other web server, and a little faster, why check -f thousands of time for a rare condition?). In cdn.example.com:

ErrorDocument 404 /redirect.pl

In redirect.pl:

#!/usr/bin/perl
print "Status: 302 Found\n";
print "Location: http://www.example.com$ENV{REDIRECT_URL}\n\n";
exit;
heyyo’s picture

question removed. resolved :-)

jcisio’s picture

Status: Reviewed & tested by the community » Fixed

Well, there are too many solutions ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.