cache-control icon indicating copy to clipboard operation
cache-control copied to clipboard

Both cases of code output is "for all responses"

Open Malvoz opened this issue 6 years ago • 0 comments

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?

Malvoz avatar Jul 30 '19 12:07 Malvoz