logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: How to stop cacheing visuals in clients browser cache
Author
clifft



Joined: 28 Nov 2021
Posts: 3
Location: Richmond

PostPosted: Sun 01 Sep '24 22:46    Post subject: How to stop cacheing visuals in clients browser cache Reply with quote

Hello,

I'm working on a Perl, mod_perl, HTML, CSS, JavaScript WWW application running on most resent Windows 11 using the Apache server. I put the following in my config file to try to prevent caching of visuals (static and dynamic content) from my application in a clients browser cache. My reason for trying to do this is that when the server software is updated with new static/dynamic content in visuals, I want to ensure that the client will see those changes.

<FilesMatch "\.(html|htm|js|css|pl|pm|cgi)$">
Header set Cache-Control "no-cache"
Header set Content-Type "text/html; charset=utf-8"
Header set X-Content-Type-Options "nosniff"
</FilesMatch>

SetEnvIf Request_URI "\.(html|htm|js|css|pl|pm|cgi)$" NO_CACHE
Header set Cache-Control "no-cache" env=NO_CACHE
Header set Content-Type "text/html; charset=utf-8" env=NO_CACHE
Header set X-Content-Type-Options "nosniff" env=NO_CACHE

ServerTokens Prod

No headers appear in the network section of developers tools and I get the following messages in the console.

A 'cache-control' header is missing or empty.
Security
Response should include 'x-content-type-options' header.

I'm running a simple HTML hello world program to see if the headers appear. I am doing this testing using my server as a client.

Any help is appreciated.

CliffT
Back to top
clifft



Joined: 28 Nov 2021
Posts: 3
Location: Richmond

PostPosted: Tue 03 Sep '24 22:06    Post subject: may not be working because it should not be done Reply with quote

Maybe this is not working because it should not be done because its already being done by the server and client cache. I read

cache policies typically apply to static assets only. Dynamic content, such as user-generated data or server-rendered pages, is usually not cached or has a much shorter cache duration to ensure that users see up-to-date information.

as the control over static content is in the hands of the website owner, making changes to it is much easier. All you need to do is ask your web development team to do the change and publish it on the live environment of your site. Browser request the server to send the static page content only when there is a new version of that page.

Unlike static content, the server does not render dynamic web pages in advance. Instead, when the user requests to open a dynamic page, the server will render the content on the spot and send it to the user (a.k.a server-side rendering).

If you all agree, this question can be closed???
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7355
Location: Germany, Next to Hamburg

PostPosted: Sun 08 Sep '24 18:25    Post subject: Reply with quote

To force the client / browser to download a resource you can add a random query. Like addin the current timestamp.

Code:

<link rel="stylesheet" href="mystyle.css
?a=1725812651">
Back to top


Reply to topic   Topic: How to stop cacheing visuals in clients browser cache View previous topic :: View next topic
Post new topic   Forum Index -> Apache