httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael A. Peters" <mpet...@domblogger.net>
Subject Re: [users@httpd] Why ExpiresByType is ignored when has SetHandler application/x-httpd-php ?
Date Wed, 28 Dec 2016 07:15:21 GMT
Oh I should add - when it is a php file I also set the cache control via 
php.

header('Cache-Control: max-age=' . $maxage);

for example.

On 12/27/2016 11:12 PM, Michael A. Peters wrote:
> Hi, I regularly use php to generate all kinds of different XML.
>
> This is what I do -
>
> header('Content-Type: application/xml');
> print($dom->saveXML());
> exit();
>
> Of course in that case $dom is a DOMDocument object - if you are using
> print or echo to create XML then you need the header at the beginning of
> the php, as it needs to be before any content is sent.
>
> Using php to send the header avoids the need to set it with Apache.
>
>
> On 12/27/2016 10:58 PM, Binyamin wrote:
>> בע"ה
>>
>> Hi,
>>
>> As I wrote in earlier example, `Header set Content-Type
>> "application/xml"` still returns 1 day expiration (not the one defined
>> in ExpiresByType).
>> The same result when switching configuration order of FilesMatch
>> before ExpiresDefault, or order of LoadModule's expires_module and
>> headers_module.
>>
>> Also this example will return expiration only 1 day, while expected 1
>> year:
>>
>>     <FilesMatch ^sitemap\.php$>
>>         Header set Content-Type "application/xml"
>>         ExpiresDefault "access plus 1 year"
>>     </FilesMatch>
>>
>> it returns
>>
>>     Content-Type: application/xml
>>     Date: Wed, 28 Dec 2016 06:38:09 GMT
>>     Expires: Thu, 29 Dec 2016 06:38:09 GMT
>>
>>
>> It seems to as a Apache bug. I don't know if ever it was working.
>>
>> Any workaround (configuration fix) for it for now?
>> Do you know if it worked right in any Apache build/version?
>>
>>
>> Binyamin
>>
>>
>> On Wed, Dec 28, 2016 at 5:29 AM, Yehuda Katz <yehuda@ymkatz.net
>> <mailto:yehuda@ymkatz.net>> wrote:
>>
>>     It might have something to do with the order the modules handle the
>>     request.
>>     What happens if you tell PHP to set the content type to
>> application/xml?
>>
>>     - Y
>>
>>     On Tue, Dec 27, 2016 at 3:55 PM, Binyamin <7raivis@inbox.lv
>>     <mailto:7raivis@inbox.lv>> wrote:
>>
>>         בע"ה
>>
>>
>>         Why ExpiresByType is ignored when has SetHandler
>>         application/x-httpd-php ?
>>
>>         /sitemap.xml Response Headers shows 1 day expiration while
>>         expected to be 1 year (1 month)
>>
>>             Content-Type: application/xml; charset=utf-8
>>             Date:         Tue, 27 Dec 2016 19:59:00 GMT
>>             Expires:      Wed, 28 Dec 2016 19:59:00 GMT
>>
>>         seems SetHandler forces it to apply text/html expiration and
>>         doesn't allow to rewrite it
>>
>>             ExpiresActive On
>>             ExpiresDefault                "access plus 1 month"
>>             ExpiresByType text/html       "access plus 1 day"
>>             ExpiresByType application/xml "access plus 1 week"
>>
>>             <FilesMatch ^sitemap\.xml$>
>>                 SetHandler application/x-httpd-php
>>                 Header set Content-Type "application/xml"
>>                 ExpiresDefault "access plus 1 year"
>>             </FilesMatch>
>>
>>         tested on Apache 2.4.X builds.
>>
>>         How to fix this issue?
>>
>>
>>
>>         Binyamin
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message