Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varnish VCL improvements #1575

Closed
nagno opened this issue Jul 28, 2015 · 2 comments
Closed

Varnish VCL improvements #1575

nagno opened this issue Jul 28, 2015 · 2 comments

Comments

@nagno
Copy link

nagno commented Jul 28, 2015

Hi,

I have some suggestions related to the Varnish VCL file.

  1. Inside vcl_recv to
    # Even though there are few possible values for Accept-Encoding, Varnish treats
    # them literally rather than semantically, so even a small difference which makes
    # no difference to the backend can reduce cache efficiency by making Varnish cache
    # too many different versions of an object.
    # https://www.varnish-cache.org/trac/wiki/FAQ/Compression
    if (req.http.Accept-Encoding) {
        if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
            # No point in compressing these
            unset req.http.Accept-Encoding;
        } elsif (req.http.Accept-Encoding ~ "gzip") {
            set req.http.Accept-Encoding = "gzip";
        } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
            set req.http.Accept-Encoding = "deflate";
        } else {
            # unkown algorithm
            unset req.http.Accept-Encoding;
        }
    }
  1. still inside vcl_recv:
    # Remove Google gclid parameters to minimize the cache objects
    set req.url = regsuball(req.url,"\?gclid=[^&]+$",""); # strips when QS = "?gclid=AAA"
    set req.url = regsuball(req.url,"\?gclid=[^&]+&","?"); # strips when QS = "?gclid=AAA&foo=bar"
    set req.url = regsuball(req.url,"&gclid=[^&]+",""); # strips when QS = "?foo=bar&gclid=AAA" or QS = "?foo=bar&gclid=AAA&bar=baz"
  1. inside vcl_hash:
    #for multi site configurations to not cache each-other's content
    if (req.http.host) {
        hash_data(req.http.host);
    } else {
        hash_data(server.ip);
    }

    # mainly to make sure, if the site was cached via a http connection and a visitor opens the 
    # https version, they won't see an ssl warning about mixed content (if the site was cached via http
    # connection, the external resources like css, js will be opened via an http connection as well
    # instead of https   
    if (req.http.X-Forwarded-Proto) {
        hash_data(req.http.X-Forwarded-Proto);
    }

What do you think about them? If you think, it is worth to add them, I'm happy to create a pull request.

@nagno
Copy link
Author

nagno commented Mar 3, 2016

The PR got merged, so I'm closing it because the issue is no longer required.

@nagno nagno closed this as completed Mar 3, 2016
@ftsf
Copy link

ftsf commented Aug 18, 2016

This should be reopened as the PR only fixes Varnish 4 output, this is still an issue for Varnish 3 VCL output.

magento-team pushed a commit that referenced this issue Oct 10, 2017
Fixed issues:
- MAGETWO-71552: Attribute values on store view level not searchable - for 2.2
- MAGETWO-72866: Redundant indexers invalidation - RIATCS-340
- MAGETWO-75458: [Backport] - Fix overwrite default value image/file with NULL #10253 - for 2.2
- MAGETWO-75460: [Backport] - LowestPriceOptionsProvider returns products without attributes which are used for price calculation (e.g. tax adjustment)
- MAGETWO-80193: [2.2.x] - Add cast to string for CUST_GROUP_ALL #10475
- MAGETWO-80204: [2.2.x] - Grammar fix for #9533 #10627
- MAGETWO-71549: Impossible to export Advanced Prices on a medium profile
- MAGETWO-80198: [2.2.x] - Fix issue #10565 #10575
- MAGETWO-80197: [2.2.x] - Fix JS translation search #10445
- MAGETWO-80195: [2.2.x] - Send different base currency in Google analytics #10508
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants