Jump to content

Generally disable caching on locally installed server


son

Recommended Posts

I am running Apache on my local machine to work on several projects. So, far so good... However, I made some changes to stylesheet and they are not coming through. Although I deleted the entire folder in htdocs folder it still refers old styling. Hence, I wanted to disable any caching for now and I changed httpd file to:LoadModule cache_module modules/mod_cache.soCacheDisable /public_htmlIn first line took the '#' out, then added the second. The website is stored in 'public_html'... Naturally, have restarted the server. Still same problem...Do I not use the right directive? The files are access from browser via 'http://localhost/public_html/index.php' etc...Son

Link to comment
Share on other sites

I believe the cache module is actually responsible for server caching, not client caching. That is, instead of reading the file from the hard disk, Apache stores the last few read files in memory, so that it can more quickly deliver them. Other directives of this module allow you to force a file into being cached, even if it's not among the last few accessed ones.So, disabling this kind of cache is only the first thing. You might want to play with the response headers to make sure you affect the client caching as well. For this, load mod_headers, and use the Headers directive, and eliminate ETags also, just in case.Here's an example configuration (haven't tested it; I usually use only the thing I'm going to show you below)

FileETag NoneHeader unset Last-ModifiedHeader set Cache-Control "no-cache, no-store, max-age=0, must-revalidate"Header set Pragma "no-cache"

And what I find enough for most cases (but which can be set in addition to the above directives) is to simply force an HTTP request by setting the Expires header with mod_expires, like:

ExpiresDefault "modification"

Link to comment
Share on other sites

I believe the cache module is actually responsible for server caching, not client caching. That is, instead of reading the file from the hard disk, Apache stores the last few read files in memory, so that it can more quickly deliver them. Other directives of this module allow you to force a file into being cached, even if it's not among the last few accessed ones.So, disabling this kind of cache is only the first thing. You might want to play with the response headers to make sure you affect the client caching as well. For this, load mod_headers, and use the Headers directive, and eliminate ETags also, just in case.Here's an example configuration (haven't tested it; I usually use only the thing I'm going to show you below)
FileETag NoneHeader unset Last-ModifiedHeader set Cache-Control "no-cache, no-store, max-age=0, must-revalidate"Header set Pragma "no-cache"

And what I find enough for most cases (but which can be set in addition to the above directives) is to simply force an HTTP request by setting the Expires header with mod_expires, like:

ExpiresDefault "modification"

Great stuff! Many thanks for info... Will try this out...Son
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...