• Resolved fedlab

    (@fedlab)


    Hi!

    I was trying to configure well the plugin, but since i am on a shared server i cannot add the rules to the nginx.config file. What do you recommend to do to avoid problems?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    generally speaking I have never seen a shared server running on nginx purely. Generally shared servers runs on Apache or Lightspeed while sometimes using nginx as a proxy. In that case there is a .htaccess file to add the rules.

    But if your shared server is purely on a nginx platform, then there is no other way than to ask your host to add the ngixn rules for your site.

    Thread Starter fedlab

    (@fedlab)

    Yes they told me it’s running with Apache and Nginx in front, i saw the rules on the htaccess file. Does that mean it’s fine and that i don’t need to add the rules on the nginx.config on the server level?

    Plugin Contributor iSaumya

    (@isaumya)

    Can you share your site URL so that I can verify if the cache control are taking effect on your site?

    Thread Starter fedlab

    (@fedlab)

    Thank you in advance!

    mosan.com

    Plugin Contributor iSaumya

    (@isaumya)

    Hi,
    for the static files I don’t see the cache control that is added by this plugin is getting reflected: https://i.imgur.com/vpctIUY.png

    Can you share your .htaccess code?

    Thread Starter fedlab

    (@fedlab)

    # BEGIN LSCACHE
    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    <IfModule LiteSpeed>
    RewriteEngine on
    CacheLookup on
    RewriteRule .* – [E=Cache-Control:no-autoflush]
    RewriteRule \.litespeed_conf\.dat – [F,L]

    ### marker CACHE RESOURCE start ###
    RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php – [E=cache-control:max-age=3600]
    ### marker CACHE RESOURCE end ###

    ### marker FAVICON start ###
    RewriteRule favicon\.ico$ – [E=cache-control:max-age=86400]
    ### marker FAVICON end ###

    ### marker DROPQS start ###
    CacheKeyModify -qs:fbclid
    CacheKeyModify -qs:gclid
    CacheKeyModify -qs:utm*
    CacheKeyModify -qs:_ga
    ### marker DROPQS end ###

    </IfModule>
    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    # END LSCACHE
    # BEGIN NON_LSCACHE
    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    # END NON_LSCACHE
    RewriteCond %{REQUEST_URI} !^/\d+\.BIN_AUTOSSL_CHECK_PL__\.\w+\.tmp$ [NC]
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/ [NC]
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*)$ https://mosan.com/$1 [R=301,L]
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{SERVER_PORT} !443
    RewriteRule ^(.*)$ https://mosan.com/$1 [R=301,L]
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://mosan.com/$1 [R=301,L]
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP:CF-Visitor} ‘”scheme”:”http”‘
    RewriteRule ^(.*)$ https://mosan.com/$1 [R=301,L]
    </IfModule>
    # END WordPress
    # BEGIN WP Cloudflare Super Page Cache
    # The directives (lines) between “BEGIN WP Cloudflare Super Page Cache” and “END WP Cloudflare Super Page Cache” are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_expires.c>
    ExpiresActive on
    ExpiresByType application/xml “access plus 0 seconds”
    ExpiresByType text/xsl “access plus 0 seconds”
    </IfModule>
    <FilesMatch “\.(xml|xsl)$”>
    <IfModule mod_headers.c>
    Header set Cache-Control “no-cache, no-store, must-revalidate, max-age=0”
    </IfModule>
    </FilesMatch>
    <FilesMatch “robots\.txt”>
    <IfModule mod_headers.c>
    Header set Cache-Control “no-cache, no-store, must-revalidate, max-age=0”
    </IfModule>
    </FilesMatch>
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^(.*)?/wp-content/wp-cloudflare-super-page-cache/mosan.com/debug.log(.*)$
    RewriteRule ^(.*)$ – [F]
    </IfModule>
    <FilesMatch “wp-cron.php”>
    <IfModule mod_headers.c>
    Header set Cache-Control “no-cache, no-store, must-revalidate, max-age=0”
    </IfModule>
    </FilesMatch>
    # END WP Cloudflare Super Page Cache

    Plugin Contributor iSaumya

    (@isaumya)

    What is adding these rules:

    ### marker CACHE RESOURCE start ###
    RewriteRule wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php – [E=cache-control:max-age=3600]
    ### marker CACHE RESOURCE end ###
    
    ### marker FAVICON start ###
    RewriteRule favicon\.ico$ – [E=cache-control:max-age=86400]
    ### marker FAVICON end ###
    
    ### marker DROPQS start ###
    CacheKeyModify -qs:fbclid
    CacheKeyModify -qs:gclid
    CacheKeyModify -qs:utm*
    CacheKeyModify -qs:_ga
    ### marker DROPQS end ###
    

    Also as I can see you are using LS cache plugin please make sure all kind of page caching mechanism is disabled on that plugin. You cannot use 2 page caching system at a time. You can only use the static file optimization inside LS cache plugin or use other plugins like Autoptimize for static file optimization.

    Also inside this plugin setting under cache tab enable the option for “Add Browser caching rule: : https://i.imgur.com/HjKVCSr.png

    Thread Starter fedlab

    (@fedlab)

    For the ### marker DROPQS start ### it says this on litespeed:
    Ignore certain query strings when caching. (LSWS v5.2.3+ required) For example, to drop parameters beginning with utm, utm* can be used here. Learn More
    One per line.

    The other two are no more in the htaccess since i disabled cache favicon.ico and cache PHP resources.

    I thought that with cache disabled on litespeed all the caching would be disabled.
    I started to use this combination to use the optimization functionalities of litespeed following this tutorial:
    https://webspeedtools.com/litespeed-cache-cloudflare/

    But after disabling all the caching in litespeed and adding browser caching rule I saw that nothing changes in the dev tools…

    Plugin Contributor iSaumya

    (@isaumya)

    I thought that with cache disabled on litespeed all the caching would be disabled.
    I started to use this combination to use the optimization functionalitie

    – As I said before you can only use lightspeed cache plugin for optimizing static files and nothing else. Also do not use the cloudflare integration of lightspeed as you are using this plugin to handle all Cloudflare and caching stuffs.

    Try removing the lightspeed cache htaccess rules and enable the add browser cache static asset rule option under the cache tab of this plugin settings as shown above.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Browser Caching Rules on shared server with nginx’ is closed to new replies.