1

My Drupal 7 site is working nice and most of my static files are served via CDN. I use CDN module with Origin Pull however CDN didn't pull the files from my misc folder where there are small png icons (came with vanilla drupal installation).

In CSS, I have used url('sites/all/themes/mytheme/img/bg.png') for background and I can see the background, and it is served via CDN. In the same CSS I have url('misc/configure.png') but this one is not working. I see 404 for configure.png while checking from Developer Tool.

So, I added the path in CDN module's whitelist like misc/*.png and did all those flushing and cron for CDN to recognize the file. Still CDN didn't pull the file. I have set the file permissions to 775 too, but nothing changed. Any help would be appreciated.

Edit: the 404 is only for the picture, I checked it via chrome's Developer tool. It shows the path https://myCDN/misc/configure.png (which is missing), whereas for background it shows https://myCDN/mysite/sites/all/themes/mytheme/img/bg.png.

However, the notable difference is in configure.png the name of my site is not present in CDN path. If I change the path via Chrome Developer Tool like https://myCDN/mysite/misc/configure.png It works, the image shows. It also works if I use absolute url in CSS like url('https://mysite/misc/configure.png')

  • I want to see what others say, but I think this may be a bug in the module. I had a similar issue a few weeks ago. I ended up *.png and *.jpg. – mpdonadio Aug 23 '13 at 13:12
  • Hello and welcome. Could you please avoid using `code ticks` for things that are not in fact a code, and add link to module name? For 404, could you provide full path your browser is trying to access, using firebug or similar tool? And could you see in your access.log if CDN attempts to ever download the file at all? – Mołot Aug 23 '13 at 13:12
  • @MPD I'll try that one, I guess it wouldn't be security risk if it is just images. – user12947 Aug 23 '13 at 13:17
  • @Mołot those code ticks are for readability, I'll try to post with different formatting if it is confusing. I'll edit the question, as it is too long to type here what I wanted to write. – user12947 Aug 23 '13 at 13:28
  • 1
    Not in the browser's address, but if I add the url path from Developer tools, it shows the image. It also works in case of absolute URL. This means, CDN is pulling the file but not serving it, or issuing wrong url. – user12947 Aug 23 '13 at 13:44
1

I was doing the wrong practices with Drupal Theme, in CSS whenever I have to use the url() to declare the path, I was using url('sites/all/themes/mytheme/images/bg.png') which is considered as Bad Practice, so I changed that to url(../images/bg.png) and same for Images inside misc folder as url('../../../../misc/configure.png') from CSS and everything is working as expected.

To tell long story in short, don't use absolute url from the root in CSS but use relative paths.

0

CDN module generates for you address like https://cdn.example.com/misc/configure.png but the URL that works is https://cdn.example.com/mysite/misc/configure.png - This means there is a bug in CDN module, in part responsible for URL generation / substitution.

The best, but not fastest course of action would be to report it in CDN module issue queue.

  • Note: I still think that question is on topic, as determining if it was in fact a bug (or if OP simply misconfigured something) was the critical point. – Mołot Aug 23 '13 at 13:57
  • There wasn't any issue with CDN module, I was doing the wrong practices in Drupal. I had conversation with module creator and corrected the issue according to his suggestion. – user12947 Aug 30 '13 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy