1

I'm trying to apply a no cache header to the style.css file in the child theme of my WordPress site, using the .htaccess file. I want to avoid having to clear my browser cache every time I make CSS styling changes to the site, in order to see the changes. Currently my cache control looks like this -

<Files ~ https://my-domain.org.au/wp-content/themes/church-suite_child_theme/style.css>
    FileEtag None
    <ifModule mod_headers.c>
        Header Unset ETag
        Header Set Cache-Control "max-age=0, no-store, no-cache, must-revalidate"
        Header Set Pragma "no-cache"
        Header Set Expires "Thu, 30 June 2022 00:00:00 GMT"
    </ifModule>
</Files>

It doesn't appear to be working. I'm using the Network Inspector in Chrome Dev Tools to view the network requests. The following is returned when I refresh the page and inspect the request -

RESPONSE HEADERS,

cache-control: max-age=31536000
content-encoding: br
content-type: text/css
date: Fri, 12 Nov 2021 01:41:45 GMT
etag: W/"6188f369-73b"
expires: Sat, 12 Nov 2022 01:41:45 GMT
host-header: 8441280b0c35cbc1147f8ba998a563a7
last-modified: Mon, 08 Nov 2021 09:52:41 GMT
server: nginx
vary: Accept-Encoding
x-proxy-cache-info: DT:1
PC888
  • 11
  • 1
  • Why don't you use the usual cache buster approach instead, that appends the last file modification timestamp as a query string parameter? – CBroe Nov 12 '21 at 07:21
  • Does this answer your question? [How can I use an .htaccess file in Nginx?](https://stackoverflow.com/questions/35766676/how-can-i-use-an-htaccess-file-in-nginx) – Joe Nov 13 '21 at 11:00
  • Your `` directive (in `.htaccess`) is incorrect and will never match. However, the response you are seeing is coming from an Nginx server, not Apache?! – MrWhite Nov 14 '21 at 23:48

0 Answers0