Website is not updating after uploading new changes in ftp - php

My website does not load the latest changes after pressing CTRL + F5
I made CSS load the latest changes by adding this to my header:
<link rel="stylesheet" href="/assets/css/main.css?v=<?php echo time(); ?>" />
But how do I make my website itself load the latest changes? For example:
From:
<h1>Hello</h1>
To:
<h1>Helloblabla</h1>
When I refresh, it does not load the newest changes. Only after ~2-5 minutes
I have searched a lot, and tried deleting my cache in my Chrome - did not work. I have tried disabling opcache by adding this line in .users.ini in the root folder:
opcache.enabled OFF
and
opcache.enabled=0
But <?php phpinfo(); ?> tells me it is still enabled... Is it my host that controls this? Is opcache causing this issue?

Changing <h1>Hello</h1> to <h1>Hellobla</h1> is purely HTML; nothing to do with CSS or its cache. Also, it's important to note that HTML and CSS actually have different caches.
To update any HTML, you'll need to actually re-upload the file back to the server. Assuming you're in an IDE, this can be done via a right-click on the file in question. If youre using cPanel or similar, directly editing the file will reflect changes immediately.
It's also possible that you've cached the old content. You can check for this by appending an additional / to the URL, which is treated as a separate page (though it shows the same content). If you see the new content, then you have indeed cached the old content.
You can refresh the HTML cache with CLTRL + F5, though the CSS cache will need a slightly different shortcut - CTRL + SHIFT + R. This is equivalent to holding SHIFT and clicking on your refresh icon.
Keep in mind that you're using a root-relative link to your CSS file: /assets/css/main.css. That is to say, your CSS should be in a folder called css, inside of a folder called assets at root level. You can confirm that this CSS file is actually getting loaded by bringing up the F12 Developer Tools and checking the Sources tab.
Also, setting the href to "/assets/css/main.css?v=<?php echo time(); ?>" will forcibly update the CSS every time you load that header. This is great for testing, but probably not ideal for production. For production, you'll probably want to just affix a version number instead, so that only major changes to the CSS file will cause a reload.
Hope this helps!

PHP is probably not configured to read configuration from .users.ini file. You can find in phpinfo() output the location of php.ini and additional configuration files.

Related

CSS file is being cached even after clearing cache and changing the CSS version

I have a css file and to test it, I added some code to the bottom that just changed the color of a small section on the site. It took about 15 minutes but eventually it loaded and updated the CSS. Then when I removed it to see how long it will take to come off again, the code still loads and it has been about 30 minutes. I tried clearing my browser cache as well as changing the version of the CSS file. The version (when I inspect the source code on the browser) is updated to v2 like it should be but the file still contains the code from v1. Would it be because of the host caching the file or something? When I ran into this problem before, changing the version of the css file worked but it is not this time. Any help would be much appreciated. Thanks!
Oh as another note I am using the below code to enque the css file and it is in WordPress:
function my_theme_styles() {
// Enqueue our style.css with our own version
wp_enqueue_style('child-theme-style', get_stylesheet_directory_uri() . '/style.css',
array(), '202107v1');
}
I also know there are other things on stackoverflow but they all just say to either clear the browser cache or to change the version at the end of the css file which both options I have already tried with no success.
#Sahriar Saikat mentioned in the comments that it could be cloudflare caching the file and he was right. I checked the settings in cloudflare (which I didn't have access to until today) and found that they were using the query level "ignore query string" which was making it not update. Thanks for your help!

Drupal css not updating after change

I'm new to Drupal and PHP. I have a project where I have updated the css and saved in in my custom theme.
My problem is that it is not updating when I refresh the page.
Is there something I have to do to make that take???
I know I have the right file and the right selector...
Thanks for any help!!
You need to go to:
Drupal > Performance > Clear cache
Or if you have installed drush, then you can run below command to clear the cache:
drush cc
Note: Adding my comment as answer, so that OP can mark the question as done/answered.
If you are working in a development or staging enviornment:
Go to Configuration -> Performance. Set page cache to no-caching.
Click 'Clear Caching', or via command line use drush cr. This will add a new 'cache-buster' query string to your css, such as main.css?dfweaf where dfweaf changes after a cache rebuild.
Look into setting up a settings.local.php and development.services.yml to disable various layers of caching while working.
While working in your browser, open developer tools and on the Network tab check 'Disable cache'. When refreshing the page, right click on the refresh icon and choose 'Empty Cache and Hard Reload' to flush your browser cache files. This works in Chrome.
If changing Javascript files, update the VERSION number in your libraries.yml file

Uploading using FTP but website not adapting to changes (not cache)

I am developing a Wordpress theme for a blog I want to start.
I am using Dreamweaver to upload my files to the server using FTP. It appears that the FTP is working perfectly. I have edited files, uploaded, then checked on the server and the changes are being made.
The problem is the changed are not showing up on my website. They are showing up maybe 5 - 10 minutes after, if at all. The strange thing is .css files work and update perfectly, but the .php files do not.
The issue does not appear to be the cache. I am clearing cache, doing hard-refreshes and using incognito to develop.
change your css links to
<link href="stack.css?ver=<?php echo rand(1,10000) ?>">
this may help
You can press ctrl+r for refresh your page and check it . if still out put not come check then follow my suggestion.
1.check your file permission
2.wordpress disabled cache.
3.check htacces

Php caching and possible generation of static files

Im running a website through the basics of a wordpress setup.
For some reason the pages/files are being cached somewhere. I haven't been able to find any static file generation but for example when i log out from a user it doesn't regonize that all cookies has been destroyed.
Also updating stylesheet and the core .php files may take a few refresh before appearing on the site.
I'v tried to set up filematch in the .Htaccess with an expiration date before the present (i had it to 1998).
Also tried inline php at the first line of my .php files to setup headers with nocache information.
None of the above has worked.
Any suggestions or clues would be much appreciated!
Also updating stylesheet and the core .php files may take a few refresh before appearing on the site.
For that when you do any change in CSS/stylesheet/JS file then after stylesheet file string pass version number like below
Before
https://stackoverflow.com/style.css?v=1.2
After
https://stackoverflow.com/style.css?v=1.3
So page caching issue is resolved.

How to hide apache server version?

1] When i open any web page & view source it. We have JS & CSS. While click on that i'm able to see each JS & CSS file.
Can we manage it like while on click .js & .css file not open
2] Website hosted on linux server. Through tools hackers are able to view Apache server version. Any way to hide it?
No, JavaScript and CSS files are open to the browser, hence they are opened to the user. You can try to obfocusate them, but that will only stall a determined user.
The server version is shown when an error (404, 500) occurs, you can override that default message with your own pages using .htaccess.
CSS and JS files will be seen by anyone and everyone . They work on HTTP ;) BTW... what you want to hide is your server-side code, like asp,jsp,php. The source code of those files cannot be seen.
To your second question:
Open your .htaccess and put the following it.
ServerSignature Off
This way, for any error, it will not show what server or version you are using.
Hope it answers you :)
When an user gets programm he gets code which will be executed. On the desktop it may be binary data for example. In web development there is no binary data, browser gets code, so user does. You may only obfocusate it.

Categories