V
V
Valentin Melnik2020-10-14 15:54:06
htaccess
Valentin Melnik, 2020-10-14 15:54:06

How to disable csv file caching via .htaaccess?

There is such .htaaccess

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} //+
RewriteRule ^(.*) $1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?)/+(/[^\s]+) [NC]
RewriteRule ^ %1%2 [R=301,L]

RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule (.*) %1/%2 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /? [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{QUERY_STRING} ^page=(1)\&
RewriteRule ^(.*)/index(.*)$ /$1? [R=301,L]

FileETag MTime Size
<ifmodule mod_expires.c>
<filesmatch ".(svg|jpg|jpeg|gif|png|ico|css|js)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</filesmatch>
</ifmodule>

#<IfModule mod_deflate.c>
#SetOutputFilter DEFLATE
#Header append Vary User-Agent
#</IfModule>

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ /$1 [R=301,L]

The problem is that the csv file is cached.
And also if you
<filesmatch ".(svg|jpg|jpeg|gif|png|ico|css|js)$">
remove, for example, png from the line, then *.png files are cached anyway.

How to make csv not cached?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yuriev, 2020-10-14
@Poincare

<FilesMatch "\.(csv)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    </IfModule>
    <IfModule mod_headers.c>
        FileETag None
        Header unset ETag
        Header unset Pragma
        Header unset Cache-Control
        Header unset Last-Modified
        Header set Pragma "no-cache"
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
    </IfModule>
</FilesMatch>

if it doesn't help, then before nginx apache or something similar that adds headers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question