• Resolved allnamestaken

    (@allnamestaken)


    Does browser cache gets disable in cloudflare when plugin is enabled? It seems that setting got changed to respect existing headers. Should I re enable it?

    Do I need to edit nginx.conf file for the plugin?

    Im trying to figure out how to enable browser cache via plugin+nginx settings or directly from cloudflare through Browser Cache TTL?

    Also I noticed that blocking time gets high when I enable bot fighting mode. I know its not related to the plugin but if you have any ideas I would appreciate it.

    Thank you in advance.

    • This topic was modified 2 years, 6 months ago by allnamestaken.
Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Does browser cache gets disable in cloudflare when plugin is enabled? It seems that setting got changed to respect existing headers. Should I re enable it?

    – No it should always remain Respect Header. Do not change it.

    Do I need to edit nginx.conf file for the plugin?

    – Yes, if you have any other nginx rule added for adding cache-control or expire header to the static files, please remove them and then inside this plugin settings under Cache tab, enable the add browser cache rule option. Then click on the link to copy the nginx rule created by the plugin and put them in your nginx.conf file.
    Screenshot: https://i.imgur.com/azlEc8P.jpeg
    Don’t forget to restart your nginx and PHP after doing this.
    This will add the proper cache-control header for your static file and telling Cloudflare to cache them properly.

    Also I noticed that blocking time gets high when I enable bot fighting mode. I know its not related to the plugin but if you have any ideas I would appreciate it.

    – It’s because when you enable bot fighting mode, Cloudflare adds a bit if JavaScript to the page which increases the blocking time. Unfortunately there is no other way for this. So, I would suggest not to inject that JS.

    Thread Starter allnamestaken

    (@allnamestaken)

    Thank you Saumya for your quick response and very good explanation. Ive added needed code to my nginx.conf but it seems that browser cache still does not work.

      GNU nano 6.0                                             mydomain.com                                                        
    server {
        server_name www.mydomain.com mydomain.com;
        access_log /srv/www/mydomain.com/logs/access.log;
        error_log /srv/www/mydomain.com/logs/error.log;
        root /srv/www/mydomain.com/public_html;
        index index.php;
    
        location / {
            try_files $uri $uri/ /index.php?$args;
        }
    
        location ~ \.php$ {
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/php-fpm/www.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}
    
    location ~* \.(xml|xsl)$ { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location /robots.txt { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location ~* \.(css|js|pdf)$ { add_header Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale>
    location ~* \.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$ { add_header Cache-Cont>
    location /wp-cron.php { add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0"; expires -1; }
    location = /wp-content/wp-cloudflare-super-page-cache/www.mydomain.com/debug.log { access_log off; deny all; }
    
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
    }
    server {
        if ($host = www.mydomain.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
        if ($host = mydomain.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot
    
        server_name www.mydomain.com mydomain.com;
        listen 80;
        return 404; # managed by Certbot
    
    }

    gtmetrix test shows Cache TTL as none.

    • This reply was modified 2 years, 6 months ago by allnamestaken.
    Plugin Contributor iSaumya

    (@isaumya)

    can you share your site URL so that I can check on my end?
    If you have added the nginx rule check the static files if they have the cache-control header as specified in the nginx config file.

    Thread Starter allnamestaken

    (@allnamestaken)

    yes here it is.
    https://www.temporary-url.com/5ECBD

    I really appreciate your help, thank you.

    Plugin Contributor iSaumya

    (@isaumya)

    I really don’t think your nginx rules are taking effect as I do not see any cache-control header for your static files. Screenshot: https://i.imgur.com/xRJ7bJY.jpeg

    Have you restarted your nginx and PHP and purged the whole cache from Cloudflare?

    Thread Starter allnamestaken

    (@allnamestaken)

    Restarting server did not help, but I believe it started to work after cache purge. Could you please confirm that it works as it should?

    Plugin Contributor iSaumya

    (@isaumya)

    Yup. All good now. The Cache Control header is now properly getting added and you got static file cache both at browser and CDN level.

    If you like the plugin, please do consider sharing a review in the review section of the plugin.

    Thread Starter allnamestaken

    (@allnamestaken)

    Just did. Thank you for your help! Also do you recommend any other performance plugins that could improve performance even further?

    • This reply was modified 2 years, 6 months ago by allnamestaken.

    @allnamestaken look in third party tab of SPCFC plugin

    Thread Starter allnamestaken

    (@allnamestaken)

    I just realized that my sitemap.xml stopped working and started displaying 404.
    I had to remove this line from nginx config to make it work
    location ~* \.(xml|xsl)$ { add_header Cache-Control “no-cache, no-store, must-revalidate, max-age=0”; expires -1; } any advice?

    Thread Starter allnamestaken

    (@allnamestaken)

    using seo framework to generate sitemap

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @allnamestaken,
    Which SEO plugin do you use to generate the sitemap? That rule that you deleted does noting but adding a proper cache control header to your sitemaps so that they doesn’t get cached in Cloudflare CDN and always gets served from the origin server.

    Also do you recommend any other performance plugins that could improve performance even further?

    – You can definitely use Perfmatters (a great plugin) and also Autoptimize if you want.

    Sorry for the delayed reply. For some reason I did not received any email for your reply.

    Thread Starter allnamestaken

    (@allnamestaken)

    Im using seo framework to generate sitemap

    Adding location ~* \.(xml|xsl)$ { add_header Cache-Control “no-cache, no-store, must-revalidate, max-age=0”; expires -1; } throws 404

    Also I dont think its related to this plugin but I have an unusual issue. If I go to my page source my meta title tags are correct, but for some reason google is using my on page titles instead of title tags set by seo framework. Updated pages have been cashed by google yet search results show different tags. I hope it makes sense…

    Plugin Contributor iSaumya

    (@isaumya)

    I honestly don’t know how that rule can through a 404. That rule is simply saying if there is a XML or xsl file in the server add that cache control header for that file when sending to users.

    Regarding Google thing. Meta Title don’t guarantee Google will use that Title. If their system think, some other part of your content works better as Title or Meta Description – they will use that.

    Thread Starter allnamestaken

    (@allnamestaken)

    Saumya so this rule does not work “location ~* \.(xml|xsl)$ { add_header Cache-Control “no-cache, no-store, must-revalidate, max-age=0”; expires -1; }” because its meant for static files and sitemap.xml does not exist as its being dynamically generated by the seo framework and I assume other plugins as well.

    I do not know if the sitemap will be cashed without the rule, but probably not since google search does not find mydomain.com/sitemap.xml

    Just sharing what I found as Im sure more people will have this issue in the future.

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘Browser Cache & nginx setting confusion’ is closed to new replies.