[GH-ISSUE #706] HTAccess - wrong mod_expire settings for audio files #500

Closed
opened 2026-02-26 02:33:23 +03:00 by kerem · 3 comments
Owner

Originally created by @skeyby on GitHub (Jan 4, 2018).
Original GitHub issue: https://github.com/koel/koel/issues/706

The default .htaccess in Koel include a mod_expire setting to leverage caching that it's broken:

<IfModule mod_expires.c>
  # Cache the audio files for 1 year.
  # It's up to the browser to respect this.
  ExpiresActive On
  ExpiresByType audio/(mpe?g3?|ogg|aac) "access plus 1 year"
  ExpiresByType audio/mp3 "access plus 1 year"
</IfModule>

The corresponding expire header is never set.

ExpireByType doesn't support regex (as stated in http://httpd.apache.org/docs/current/mod/mod_expires.html#expiresbytype), thus the rule must be corrected/exploded to all the possible matches:

<IfModule mod_expires.c>
  # Cache the audio files for 1 year.
  # It's up to the browser to respect this.
  ExpiresActive On
  ExpiresByType audio/mp3 "access plus 1 year"
  ExpiresByType audio/mpg "access plus 1 year"
  ExpiresByType audio/ogg "access plus 1 year"
  ExpiresByType audio/aac "access plus 1 year"
</IfModule>

The corresponding Expire header will instantly appear.

As a side note, it could be useful to add an expiration to cover images as well.

Originally created by @skeyby on GitHub (Jan 4, 2018). Original GitHub issue: https://github.com/koel/koel/issues/706 The default .htaccess in Koel include a mod_expire setting to leverage caching that it's broken: ``` <IfModule mod_expires.c> # Cache the audio files for 1 year. # It's up to the browser to respect this. ExpiresActive On ExpiresByType audio/(mpe?g3?|ogg|aac) "access plus 1 year" ExpiresByType audio/mp3 "access plus 1 year" </IfModule> ``` The corresponding expire header is never set. ExpireByType doesn't support regex (as stated in http://httpd.apache.org/docs/current/mod/mod_expires.html#expiresbytype), thus the rule must be corrected/exploded to all the possible matches: ``` <IfModule mod_expires.c> # Cache the audio files for 1 year. # It's up to the browser to respect this. ExpiresActive On ExpiresByType audio/mp3 "access plus 1 year" ExpiresByType audio/mpg "access plus 1 year" ExpiresByType audio/ogg "access plus 1 year" ExpiresByType audio/aac "access plus 1 year" </IfModule> ``` The corresponding Expire header will instantly appear. As a side note, it could be useful to add an expiration to cover images as well.
kerem closed this issue 2026-02-26 02:33:23 +03:00
Author
Owner

@skeyby commented on GitHub (Jan 4, 2018):

ExpiresByType audio/m4a "access plus 1 year"

is missing as well.

<!-- gh-comment-id:355242772 --> @skeyby commented on GitHub (Jan 4, 2018): ExpiresByType audio/m4a "access plus 1 year" is missing as well.
Author
Owner

@phanan commented on GitHub (Jan 4, 2018):

Thanks @skeyby. Do you want to send a PR over?

<!-- gh-comment-id:355344553 --> @phanan commented on GitHub (Jan 4, 2018): Thanks @skeyby. Do you want to send a PR over?
Author
Owner

@phanan commented on GitHub (Apr 14, 2018):

Fixes in e11e9d1.

<!-- gh-comment-id:381359794 --> @phanan commented on GitHub (Apr 14, 2018): Fixes in e11e9d1.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#500
No description provided.