Conditional headers

#1
Is there a way to set headers based on some condition? In Apache I could use <IF> statement or something like
Apache config:
set Cache-Control "max-age=2592000,public" "expr=%{CONTENT_TYPE} =~ m#image/svg\+xml#i"
but I do not see a way to do that in OLS. Or am I missing something?
 
#3
Do I have to use them in an .htaccess file specifically? Because I've tried IF conditions in "Context" module's headers and it did not work: OLS generated headers with those names, instead.
Are Litespeed's differences in expressions support documented somewhere?
 

LiteCache

Active Member
#4
Do I have to use them in an .htaccess file specifically?
Yes, where else? ;)

LiteSpeed supports it, but as already said, it is limited. With the last update, the compatibility with Apache was extended, at least with the LSWS. Unfortunately, I don't know whether this range of functions was also implemented in OLS.
 
#5
Well, it would have made sense to support that in the headers section directly, as well Will try using what we have, though. Thanks for the info.
 
#6
Hm... Does it really read the headers from .htaccess, though? I tried just "Header set x-test-htaccess true" (for test purpose) and
Apache config:
<IfModule headers_module>
    Header set x-test-htaccess true
</IfModule>
But the header was not added, even though, I know that .htaccess file was read, since to ensure that, I moved the rewrite rules from "/" context to it. And, of course, I've restarted the server after each change.
 

LiteCache

Active Member
#9
Is there a way to set headers based on some condition? In Apache I could use <IF> statement or something like
Apache config:
set Cache-Control "max-age=2592000,public" "expr=%{CONTENT_TYPE} =~ m#image/svg\+xml#i"
but I do not see a way to do that in OLS. Or am I missing something?
What about this?

Apache config:
<FilesMatch "\.(svg|xml)$">
    Header set Cache-Control "public,max-age=2592000"
</FilesMatch>
 

LiteCache

Active Member
#11
And this? It works with LSWS.

Code:
SetEnvIf HEADERS ^ HEADERS
SetEnvIf Request_URI "\.(svg|xml?.)$" !HEADERS
Header set Cache-Control "public,max-age=2592000" env=HEADERS
 

LiteCache

Active Member
#12
or this? Works with LSWS

Apache config:
RewriteCond %{REQUEST_URI} \.(svg|xml?.)$
RewriteRule ^.*$ - [ENV=HEADERS:true]
Header set Cache-Control "public,max-age=2592000" env=HEADERS
 
#15
Can it be that processing it may require some other settings? or maybe disabling something?

Offtopic, but if I would consider LSWS starter: how many workers OLS use?
 
Top