I've been hitting a problem with the audio module when I enable drupal page caching, it seems to come down to the audio_file_transfer() function. For the /audio/download/$nid/$file URL Drupal caches drupal_not_found(). I don't know exactly why, but I'd presume that the caching mechanism does not accommodate caching of the audio file that is piped through the audio_file_transfer() function.
The best option would be to help the caching module understand and cache the audio file. Second would be to exclude audio/download from the caching mechanism, I tried to do this with the cache_exclude module but was unable to get this to work. Both of these options if possible are beyond me at the moment, I was unable to find ways to do this.
So to settle for the third idea I created an admin setting to have the audio module link directly to the audio file instead of piping it through the audio_file_transfer() function. This will lose download stats in Drupal but it will allow me to enable caching. Not to mention downloading mp3 files straight off of disk instead of piping it through php should take less server resources.
Attached are the modifications I made to audio.module to allow the admin to select either the default method or to direct link to the audio file.
Comment | File | Size | Author |
---|---|---|---|
direct_download.patch | 2.1 KB | jeffbearer |
Comments
Comment #1
VM CreditAttribution: VM commentedComment #2
drewish CreditAttribution: drewish commentedthoughts on: #315126: Remove audio_file_transfer() and use drupal_goto() to redirect to download ?
Comment #3
jeffbearer CreditAttribution: jeffbearer commentedComments on 315126:
I tried to do something similar to drupal_goto() but not that function exactly (i'm still an api newb) but itunes did not like a http redirection at the enclosure url. It failed to download the file. I did not test other podcast aggregators.
Comment #4
drewish CreditAttribution: drewish commentedjeffbearer, according to http://www.apple.com/itunes/whatson/podcasts/specs.html#tracking itunes will redirect 5 times and basically that clean URLs need to be enabled.