JasonDavis
JasonDavis

Reputation: 48933

Is a 304 Not Modified the same as Caching the resource?

Below is the .htaccess file I am working on for a wordpress blog/

I am trying to cache images, javascript, and css files. When I view in Chrome dev tools, instead of caching these files, it says 304 not modified I am wondering why it is not caching instead? Any ideas? I am stuck on a shared host so I have to use .htaccess file

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^assets/css/(.*) /wp-content/themes/codedevelopr/assets/css/$1 [QSA,L]
RewriteRule ^assets/js/(.*) /wp-content/themes/codedevelopr/assets/js/$1 [QSA,L]
RewriteRule ^assets/images/(.*) /wp-content/themes/codedevelopr/assets/images/$1 [QSA,L]
RewriteRule ^assets/fonts/(.*) /wp-content/themes/codedevelopr/assets/fonts/$1 [QSA,L]
RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


# cache images and flash content for one month
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

# cache text, css, and javascript files for one week
<FilesMatch ".(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>

# cache html and htm files for one day
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>

# explicitly disable caching for scripts and other dynamic files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>



# use utf-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8
# force utf-8 for a number of file formats
AddCharset utf-8 .html .css .js .xml .json .rss

Upvotes: 1

Views: 1762

Answers (1)

Konerak
Konerak

Reputation: 39763

304 not modified is what the server replies when you send a conditional GET request, with Etag or the if-modified-since pragmata in the headers.

The server will only reply with that header, and not include any response body.

So yes, your Chrome is actually cashing the request.

Upvotes: 2

Related Questions