Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Apache Cache Question

Status
Not open for further replies.

AbidingDude

Programmer
Oct 7, 2012
74
0
0
US
I'm not great with web servers, and I'm especially new to Apache. (The only other web server I used was Abyss in Windows.)
I copied a couple html files from my old Windows drive to the Linux Apache directory. Loaded it. Realized I needed to update a path to a JS file. When I refreshed, I saw no change. I pressed Ctrl+U to see the page source. The path had not been updated. Ok. I figured it must be pulling from cache. I pressed Ctrl+F5 to pull from disk. No change. How do I flush Apache cache?
I also wouldn't mind disabling it altogether because I don't see the point of caching on localhost.
 
Hi

Are you sure ? I can not remember in ~20 years of using Apache I ever had caching issue.

To start with warmup questions :
[ul]
[li]How you installed Apache ?[/li]
[li]What do you mean by "the Linux Apache directory" ?[/li]
[/ul]

Feherke.
feherke.github.io
 
No I'm not sure [upsidedown]. I'm still quite new to this...
I actually don't remember how I installed Apache. I don't remember if it just came with my distribution of Mint, or if I did "sudo apt-get install apache2" afterward.
For the directory, I just meant the main directory where I'm supposed to put my html files, which in Linux is apparently:
/var/
 
Hi

AbidingDude said:
I don't remember if it just came with my distribution of Mint, or if I did "sudo apt-get install apache2" afterward.
Ok, the reason I asked was to know whether you used some spooky 3-in-1 LAMP installer, which may add obscure configurations.

AbidingDude said:
For the directory, I just meant the main directory where I'm supposed to put my html files, which in Linux is apparently:
/var/www/html
Yes, that used to be, though the precise answer is whatever is specified with the [tt]DocumentRoot[/tt] directive.

Tried with a Mint live CD now :
[ul]
[li]Installed the apache2 package, made no configuration[/li]
[li]Created a test.html and a test.js file in /var/ with test.html referring to testosterone.js[/li]
[li]Loaded the document appeared as expected[/li]
[li]Edited test.html to refer to test.js[/li]
[li]Hit [kbd]Ctrl[/kbd]-[kbd]F5[/kbd], the document was reloaded with the modifications made by JavaScript visible[/li]
[/ul]

No idea what could be wrong there, just some dumb questions :
[ul]
[li]Are you sure the URL you use to access the page is correct ?[/li]
[li]Are you using a plain text editor that certainly does no backup, versioning or similar thing the could send the content to other file than you expect ? ( Personally I used MCEdit, the Midnight Commanders's builtin editor. )[/li]
[li]Are you editing the file on the local file system ? ( I mean, not through network on shared drive. )[/li]
[/ul]


Feherke.
feherke.github.io
 
Cache is something that can be affected at both the client and server side. Without knowing exactly what is happening here (or in any other caching scenario), the standard practice is to append a GET variable to the end of your file reference. In your HTML, change "myscript.js" to "myscript.js?t=3". This typically tricks both servers and clients into sharing a fresh version of the file.

 
Apparently I was mistaken. The change I made to the script path was too subtle. The reason I thought the change had no effect was because when I hit Ctrl+U to view the page source, it was the source before the change, so I thought it was the old page loading.
Just now I changed the CSS. I changed the background color from
rgb(20, 20, 20)
to
rgb(50, 0, 10)
then I refreshed the page and saw immediately that it changed to a dark red. But the strange thing is that when I hit Ctrl+U again, the source that popped up was the old one with the previous color.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top