If an image/file is changed, does the header expire? - apache

This is probably a dumb question but I couldn't find an answer anywhere.
I recently added mod_deflate and cache control to my htaccess:
<FilesMatch "\.(txt|xml|js|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
My question was, if I update a CSS sheet, will my visitors' browser figure out that it's been modified or will it completely ignore it and won't grab it again until it expires (a week after) ?
Thanks

Related

Caching issue with Apache; css and html not updating

I've recently setup a vps on Ubuntu 20.04 to host a single website amongst other non-apache related things. I've been attempting to work on my site but it seems that the files are being cached. For instance, I can still access the webpage and stylesheet even though its been deleted. Thus far I've spent a couple hours searching for a solution to this. I've looked through here, this and this. I've also tried the suggestion of one place in adding to my .htaccess as follows:
#Initialize mod_rewrite
RewriteEngine On
<FilesMatch "\.(html|htm|js|css)$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"
</IfModule>
</FilesMatch>
After adding that, restarting apache but still with no success. I've found other posts seemingly with the same issue as me which talk about editing 000-default.conf but I lack the technical understanding of apache to be able to make informed choices on editing things like that out of fear of breaking something.
I believe that apache caching is my issue but I could well be wrong. I can't think of what else it would be though. I think this is an issue I've had in the past but I don't remember the solution. Thanks for any help
Adding ?v=1.x.x to the end of the stylesheet URL fixed the issue. Credit to a Reddit user here

Apache2 no cache specific file only

I'm running and Amazon EC2 with Ubuntu 14.4 and Apache2 with no PHP or other server-side script--just a static content site. I used this tutorial to get to the point I am at now with the apache file (see screenshot at link below):
https://www.digitalocean.com/community/tutorials/how-to-configure-apache-content-caching-on-ubuntu-14-04
I want to have a directive (if that is the nomenclature) that tells Apache to not cache a single, specific file only, but still handle everything else as it is already configured. I'm no computer whizz here--just learning. Is there a way to do this? Currently I have made a new directory inside my images folder called "no-cache" where the image I do not want cached lives.
I tried adding a second location tag below the first one with "CacheDisable on" inside it, however this is not supported. Also tried using a Directory tag, but this also does not work with the current configuration.
Thanks in advance!
/etc/apache2/sites-enabled/000.default.conf
The link you provided is a bit confusing since it mentions so many different types of caching.
When dealing with Webservers and caching, what you usually mean is sending cache messages (using http headers) to define how the browser should handle caching, to improve visitors performance. This is the last item discussed in that link of yours, despite being the most common. The first section talks about Apache caching files itself to improve its own performance and is much less common.
If client side caching using mod_expiries is what you mean, then you can control this with location headings:
#Allow long term assets to be cached for 6 months as they are versioned and should never change
<Location /assets/libraries/ >
ExpiresDefault A15724800
Header set Cache-Control "public"
</Location>
#Do not cache these files
<Location /login >
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
</Location>
I've a more detailed blog on this here: https://www.tunetheweb.com/performance/http-performance-headers/caching/.

How to Change Response Headers - Pragma & Cache-Control

I'm using Font Awesome in my web application but none of my icons are displaying in Internet Explorer 11. Per their troubleshooting guide
I learned that this behavior can be tied to the no-store Cache-control header, or the no-cache Pragma header.
How can I change these header values?
Ideally, there would be some option in the IE developer tools where I can adjust this, but this does not seem possible. I have been playing around on my web server - Apache 2.4 (Debian) - and attempted the following in my sites-enabled configuration:
<FilesMatch "\.(eot|woff|ttf|svg|otf)$">
<ifModule mod_headers.c>
Header unset Cache-Control
Header unset Pragma
</ifModule>
</FilesMatch>
I reloaded Apache and no change, these Headers are still set, my icons are still not displayed in Internet Explorer.
I don't have that much experience with Apache, I could really use some help here! Thanks in advance.

If a file is updated on a server, will the header expire on visitors' browser?

This is without a doubt a dumb question but I can't seem to find an answer to it.
I just added mod_deflate and header expire in my htaccess
<FilesMatch "\.(txt|xml|js|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
My question was, if I update a CSS sheet, will my visitors' browser figure out that it's been modified or will it completely ignore it and won't grab it again until it expires (a week after) ?
Thanks

How to set expires tags on images that are on a CDN

My site runs on Apache and I have set expires headers in my .htaccess file like so:
<ifmodule mod_expires.c>
<FilesMatch "\.(ico|jpg|jpeg|png|gif|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
Header append Cache-Control "public"
</FilesMatch>
</ifmodule>
This works great for images that come from my domain. However, 95% of my images are hosted on a cdn called CDN77, which runs on Nginx.
When I run Yslow on my site, it says that all the images being served from CDN77 do not have expires set. I have also confirmed the expires header is not set for those images by viewing the headers in LiveHTTP (Firefox headers viewer plugin).
CDN77 has said they have no way on their end to configure this.
Any thoughts or ideas as to how to set the expires for the images served from the cdn?
Change your CDN. First of all, they SHOULD allow clients to create exceptions for headers and nginx has a very elaborate configuration set for that. Secondly, the default mode should be to copy response headers from the upstream server (you), and only change or add headers that is specific to the CDN, like the host header, server header and strip any cookie headers you may be sending.
You’re not able to set expiry headers on files that are hosted on CDN77. If you require custom cache headers, you’ll need to contact their support department.
Expiry headers will be applied to all files on your CDN. It’s not possible to apply different expiry values to indiviudal files or specific file types.