Skip to content
This repository was archived by the owner on Feb 15, 2022. It is now read-only.

Both cases of code output is "for all responses" #5

Open
Malvoz opened this issue Jul 30, 2019 · 0 comments
Open

Both cases of code output is "for all responses" #5

Malvoz opened this issue Jul 30, 2019 · 0 comments

Comments

@Malvoz
Copy link

Malvoz commented Jul 30, 2019

Taking Apache as an example, the code output may look like this:

# for all responses
<IfModule mod_headers.c>
  Header set "Cache-Control" 'no-cache'
</IfModule>

# for single response
Header set "Cache-Control" 'no-cache'

Actually both these cases set the header for all responses.

If you want a header only to be included in a response for certain files based on file extension you could use e.g. <FilesMatch>, or preferably based on MIME type using expr.

<IfModule mod_headers.c>

  # Based on file extension:
  <FilesMatch "\.(htm|html)$">
    Header set Cache-Control "no-cache"
  </FilesMatch>

  # Based on MIME-Type:
    Header set Cache-Control "no-cache" "expr=%{CONTENT_TYPE} =~ m#text/html#i

</IfModule>

Perhaps there could be an option to choose which MIME-types or file extensions the build should apply to?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant