How to Configure .htaccess to Not Save Cache

Asked 2 years ago, Updated 2 years ago, 326 views

I am currently creating a site locally using VirtualBox in WordPress.

Every time I change the code, the cache is left, and every time I create a site, I have to erase the cache.

It takes a lot of time and effort, so I'm trying to edit .htaccess and set it to not save the cache, but I'm not sure because it uses code that I've never touched before,
For the time being, I entered it as below, but it doesn't work.

#BEGIN WpFastestCache
# Modified Time:07-01-22 16:24:21
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond%{HTTPS} = on
RewriteCond%{HTTP_HOST}^pacificmall.local
# Start WPFC Exclude
# End WPFC Exclude
# Start_WPFC_Exclude_Admin_Cookie
RewriteCond%{HTTP:Cookie}!wordpress_logged_in_[^\=]+\=kei
# End_WPFC_Exclude_Admin_Cookie
RewriteCond%{HTTP_HOST}^pacificmall.local
RewriteCond%{HTTP_USER_AGENT}! (facebookexternalhit | WP_FASTEST_CACHE_CSS_VALIDATOR | Twitterbot | LinkedInBot | WhatsApp | Mediatoolkitbot)
RewriteCond%{HTTP_USER_AGENT}!(WP\sFastest\sCache\sPreload(\siPhone\sMobile)?\s*Bot)
US>RewriteCond%{REQUEST_METHOD}! POST
RewriteCond %{REQUEST_URI} !(\/){2}$
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:Cookie} !wordpress_logged_in
RewriteCond %{HTTP:Cookie} !comment_author_
RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP_USER_AGENT} !^.*\bCrMo\b|CriOS|Android.*Chrome\/[.0-9]*\s(Mobile)?|\bDolfin\b|Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+|Coast\/[0-9.]+|Skyfire|Mobile\sSafari\/[.0-9]*\sEdge|IEMobile|MSIEMobile|fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS|bolt|teashark|Blazer|Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari|Tizen|UC.*Browser|UCWEB|baiduboxapp|baidubrowser|DiigoBrowser|Puffin|\bMercury\b|Obigo|NF-Browser|NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger|Android.*PaleMoon|Mobile.*PaleMoon|Android|blackberry|\bBB10\b|rim\stablet\sos|PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino|Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b|Windows\sCE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window\sMobile|Windows\sPhone\s[0-9.]+|WCE;|Windows\sPhone\s10.0|Windows\sPhone\s8.1|Windows\sPhone\s8.0|Windows\sPhone\sOS|XBLWP7|ZuneWP7|Windows\sNT\s6\.[23]\;\sARM\;|\biPhone.*Mobile|\biPod|\biPad|Apple-iPhone7C2|MeeGo|Maemo|J2ME\/|\bMIDP\b|\bCLDC\b|webOS|hpwOS|\bBada\b|BREW.*$ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /home/kusanagi/pacificmall/DocumentRoot/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]
</IfModule>
<FilesMatch"index\.(html|htm)$">
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
FileETag None
Header unset ETag
Header set Cache-Control "max-age = 0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Mon, 29 Oct 1923 20:30 GMT"
</ifModule>
</FilesMatch>
# END WpFastestCache


<Files~"^\.ht">
    Deny from all
</Files>

<Files wp-login.php>
    Order deny, allow
    Deny from all
    Allow from all
    # Allow from 127.0.0.1
    AuthType Basic
    AuthName "ENTER YOUR NAME & PASSWORD TO LOGIN"
    AuthUserFile/home/kusanagi/.htpasswd
    Require valid-user
    Satisfy any
</Files>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase/
    RewriteRule^index\.php$ - [L]
    RewriteCond%{REQUEST_URI}!\.(gif|css|js|swf|jpeg|jpg|jpe|png|ico|swd|pdf|svg|eot|ttf|woff)$
    US>RewriteCon%{REQUEST_FILENAME}!-f
    RewriteCon%{REQUEST_FILENAME}!-d
    RewriteRule./index.php [L]
</IfModule>

<IfModule mod_expires.c>
 # Do not cache data
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/ld+json "access plus 0 seconds"
    ExpiresByType application/schema+json "access plus 0 seconds"
    ExpiresByType application /vnd.geo + json "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType text/xml    
</IfModule>

How do I type in .htaccess to increase cache storage?
This is the site I used as a reference.

.htaccess Writing (Speed Up)

I would appreciate it if you could let me know if there is a way that I don't have to delete the cache once without editing .htaccess.

wordpress .htaccess

2022-09-30 22:01

1 Answers

You were able to disable the cache by checking "Disable cache" on the Network tab of the verification tool.


2022-09-30 22:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.