Is there a way to identify what is Caching a particular file? - wordpress

I am having a prolonged issue with the Cart file, on an ecommerce website I am working on. The WordPress powered website, is using WooCommerce as the preferred shopping platform. Simply, the Cart file is being Cached by the Browser and I cannot seem to prevent this.
I have tried many avenues but to no success. Is there a way to identify what is caching the 'cart.php' file, in a bid to narrow down my focus on where the problem(s) could lie? I have no Caching Plugins, my hosting provider has stated there are no server side caching resources, there are no issues with the theme and I have not modified the '.htaccess' file, to cache any files.
Hopefully, knowing what is causing the Caching, will help resolve the problem.

Please check wp_config.php define('WP_CACHE', false) .

I think the problem is with browser cache.. as you stated you have already asked your service provider and they dont have any cache in server and u didnt use any third party plugins either... Whenever u try to refresh use hard refresh( ctrl+shift+R ) for windows and ( cmd+shift+R ) for mac.. Sometimes browser cache can give lots of headache

I have resolved the problem. I totally forgot I placed the following Caching Code into my .htaccess file. As soon as the below code was removed, the problem was resolved.
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

Related

Leverage browser caching not working

im building a new site and i'm trying to improve its speed and page rank. One of the problems i have is Leverage browser caching. I've read online different solutions, but none of them seems to work for me. I edited the .htaccess file and added the following code:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
I still cannot fix the error. Also, Gtmetrix report shows that the problem is only with my front page images. (I'm using wordpress and front page is a static page).
Is there a way to add expiry header to specific files by location ?
Thanks in advance :)
That codes works only in apache service.
please inter your website address.
for more information:
https://gtmetrix.com/leverage-browser-caching.html
https://developers.google.com/speed/docs/insights/LeverageBrowserCaching
I have just resolved it. You have to enable mod_expires module. Have a look on my answer :- Leverage browser caching not working - Htaccess & mod_expires Active

Difference between meta cache tag and htaccess caching?

I currently have this in my .htaccess file for resource caching:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
Do I also need the Cache-Control meta tag on my pages for these rules to apply? i.e.
<meta http-equiv="Cache-control" content="public">
Both are setting different headers and values, the result in the browser will be the same whichever method you are using. The main difference is in the type of files each can apply to:
*a <meta> tag can only appear inside an HTML document; consequently, you cannot use it to control cache validity on non-HTML files (such as images), and it's possible that something would download the file without processing the HTML and spotting the tag.*
*the Apache Header directive (not part of mod_rewrite) can be applied to any file that Apache is serving, whether it is dynamically generated or not. This can include images, static HTML, CSS, and JS, plus whatever content you generate with PHP.*
The only disadvantage of the Apache directive is that depending on your setup and experience with Apache's configuration rules, it may be difficult to maintain more complex rules for different bits of data.
You may want to give it a try using PHP like below:
the PHP header() function can affect any file that you are serving dynamically with PHP. This could include, for instance, plain text or XML files, but might not include an HTML file you'd uploaded fully formed to your server. You could pass static files, including images, through PHP, but this would be an inefficient way of serving them.

How to enable browser caching of assets (images/JS/CSS) in Symfony2?

I am working on a Symfony2 application that uses a lot of images, JS and CSS files.
I would like the browser to cache these aggressively, so that the majority of pageloads will not re-requests these assets.
The default appears to be for the browser to keep re-checking them and for the server to respond with a 304 Not Modified. How do I change this so that it doesn’t even run this request? (I don’t mind if it uses ETag or Expires or whatever mechanism, just as long as the majority of page requests don’t run separate requests for all the images.)
I’ve googled around a lot and found a lot of information on how to do this for pages where you have a $request object in your controller that you can set various properties on. However, I’m asking how to do this for assets (such as images) which are not returned by any of my PHP code.
You must add this in your httpd.conf file :
ExpiresActive On
ExpiresByType image/gif "access 1 month"
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/js "access 1 week"
ExpiresByType application/javascript "access 1 week"
The module 'mod_expires' must be activated
Also, don't forget to add an asset_version in your config file (see http://symfony.com/doc/current/reference/configuration/framework.html#ref-framework-assets-version), in order to invalidate cache when you change some asset
It is not for your web server, but for someone who use nginx+symfony the solution is:
Edit config.yml to enamle asset version control it describer here
#app/config/config.yml
framework:
# ...
assets:
version: 'v2'
Where 'v2' - is your custom asset verion name.
Edit your nginx config as it described here
server {
...
location ~* ^.+\.(rss|atom|jpg|jpeg|gif|png|ico|rtf|js|css)$ {
expires max;
}
...
}
Now all your assets will have the longest expiration period.
If your make new release and change some .css and .js files, just edit version name eg. from 'v2' to 'v3'.

WordPress images reloaded when refreshing a page (I don't want it to)

When I refresh the page, it reloads the images which is something I don't want
I am working on two WordPress blogs, on two different servers. http://www.i-phony.com/ & http://www.dz-ahbeb.com.
They have the same exact template. But the is a problem is only with the first website. even though the settings are the same.
I tried disabling plugins and the problem was still there.
What do you suggest?
Thanks everyone
Update:
I added this to the .htacess file, and it made the blog load much faster, which means it saves cache, but I still can see the images "flash" they disappear before they appear again.
<IfModule mod_expires.c>
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
Looks to me like this is performance related. It's not that the logo isn't loading quick enough, it's that it's being requested too late.
If you look at a waterfall report for the i-phony site you'll see that the logo and the rest of the images are loading quite late. It's loading the logo file (request 33) way after it's loading a bunch of blocking javascript.
The other site is loading the logo and images much earlier (see waterfall here request 10) and loading the javascript much later to prevent it blocking the page render.
There are a few things you can do to speed up the loading of the images. Firstly I suggest you load as much of the javascript in the footer as you can and combine & minify as many css and javascript files as you can to lower the transfer amount and total requests.
You can use a plugin like W3 Total Cache to combine+minify+defer the js to footer without needing to make any changes to the underlying code.
Are they on the same server? It is possible that browser.cache header is different in different environments.
There are browser cache directives that can be sent to tell the client's browser how long to keep page objects like images, media content, page html, stylesheets, javascripts, etc in the local client browser cache before trying to refresh. These directives are enabled through DSO modules (apache web server), server configuration and .htaccess file entries.
Example apache directive
#Set caching on image files for 11 months
<filesMatch "\.(ico|gif|jpg|png)$">
ExpiresActive On
ExpiresDefault "access plus 11 month"
Header append Cache-Control "public"
</filesMatch>

error code in WordPress: {"code":0,"url":""}

My WordPress website stopped displaying images in my portfolio. When O logged in to the CP, I see this error {"code":0,"url":""} in many places like: when load official wp feeds, when try to add blocks, when try to add images or edit pages.
Do you have any suggestion?
I did google it without any solution.
Thanks
You may want to try adding this to the top of your .htaccess file,
I had the same issue and this resolved it:
## EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
## EXPIRES CACHING ##
This should help page load in the future too!
These file types will be cached in order to improve faster loading times in the future.
Hope that helps.
Also if Yahoo is okay leave it be unless you start to get the same error.

Resources