Leverage browser caching not working - wordpress

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

Related

Switching language in polylang

I have a problem with polylang.
For example, the default language is PL and additional EN and DE. Everything is good, but when you switch to EN and close the browser, after entering the main domain again, EN is active. Clicking on PL it does not want to switch anything and in the address bar is always www.mypage.pl/en/. Even if I remove it from the address en it goes back to it.
Cleaning cookies in the browser does not give anything.
What may be the problem? How to fix it?
Thanks in advance for reply.
ok, I solved the problem by removing the following code from the htaccess file:
<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>

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

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 ##

How to cache style.min.css and Google font in Wordpress [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm told I should cache the above resources in order to optimise my site, but I can't seem to find/understand instructions for doing so. What are the manual instructions for caching this info, and where do I put them?
Use .htaccess for compressing and caching. Add this to your .htaccess. Please backup your .htaccess before doing this (Just for safety). This will apply to all cacheable resources.
<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>
You can use a Content Delivery Network (CDN) for this as well.
CDN will speed up your site loading time.
Please take a look in here for a better understanding :
http://premium.wpmudev.org/blog/top-cdn-services-to-make-your-wordpress-site-blazingly-fast/

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.

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