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

Multi-language support for WooCommerce (slugs) skip cache rules #43

Open
Bronislawsky opened this issue May 19, 2020 · 7 comments
Open

Comments

@Bronislawsky
Copy link

Bronislawsky commented May 19, 2020

/sites-enables/default

    ## sensitive wordpress urls should always skip the cache
    if ($request_uri ~* "index.php|/account.*|/cart.*|/checkout.*|/contact.*|/dashboard.*|/login.*|/my-.*|/order.*|/profile.*|/register.*|/settings.*|/view.*|/wc-api.*|/wp-admin.*|wp-.*.php") {
        set $skip_cache 1;
    }

In french, we use panier instead of cart etc,

Is it a possibility to eventually add multilang support or a custom skip cache options for
other language than English ?

@jessuppi
Copy link
Member

@Bronislawsky It is something that I've thought about since the beginning, however I'm not sure what the best approach would be. Obviously yes, including every single common URI slug in dozens of languages by default would not be very manageable.

So yah, probably it would need a variable in ss-config for custom slugs to skip cache.

That said, I'd also love to be able to popularize certain URIs (spellings) for commonality/SEO... I'm not a fan of needlessly complex slugs like shopping-cart instead of just cart etc.

@backamblock
Copy link
Contributor

backamblock commented Jan 19, 2022

suggestion:
ask about language in the installer script and link it to a file in your repository. everybody who needs a language should contribute the file with the correct translations.
Workaround for not yet accepted contributions: set own URL or path to language files in the ss-config

example file: "de_DE.txt"

cart="warenkorb"
account="mein-konto"
checkout="checkout"
contact="kontakt"
.....

this is just an example, i don't have the correct slugs in my head right now.

another, easier, way would be to set the initial exclusions in english, then get the current values of woocommerce on each ss-update.
this way the user would not need to install everything a second time after reading his config and writing the file.
but i guess this would involve more coding

@backamblock
Copy link
Contributor

backamblock commented Jan 22, 2022

In french, we use panier instead of cart etc,

Is it a possibility to eventually add multilang support or a custom skip cache options for
other language than English ?

can you please insert the correct values here @Bronislawsky and i will add them to my fork. they may get pulled to this repo

    ## FRENCH - sensitive wordpress urls should always skip the cache
    if ($request_uri ~* "index.php|/account.*|/cart.*|/checkout.*|/contact.*|/dashboard.*|/login.*|/my-.*|/order.*|/profile.*|/register.*|/settings.*|/view.*|/wc-api.*|/wp-admin.*|wp-.*.php") {
        set $skip_cache 1;
    }

@jessuppi
Copy link
Member

As an aside, I mentioned this on the Pull Request but to begin considering support for 100 languages we should probably move the skip cache rules into a new Nginx module instead like:

/etc/nginx/conf.d/skip-cache.conf ... or something where users only install the skip cache rules for one language.

Ref: #141

@jessuppi jessuppi changed the title Multilang woocommerce support Multi-language support for WooCommerce skip cache rules Jan 22, 2022
@jessuppi jessuppi changed the title Multi-language support for WooCommerce skip cache rules Multi-language support for WooCommerce (slugs) skip cache rules Jan 22, 2022
@jessuppi
Copy link
Member

I don't know yet how to implement, but here's an example file:

https://github.com/littlebizzy/slickstack/blob/master/modules/nginx/languages/en_us.txt

By separating files like this, it makes it easier for users to contribute spelling fixes and other patches. And, it means each SlickStack server only needs to install the languages that they will use.

@jessuppi
Copy link
Member

jessuppi commented Mar 5, 2024

New location:

https://github.com/littlebizzy/slickstack/blob/master/languages/en_us.txt

## notes for future: hardcoding nginx skip cache rules per each language is too limiting...
## we probably need centralized language files like WordPress Core does, to be used for whatever purposes 
## need to decide on a format and how to extract various terms

@jessuppi
Copy link
Member

Some general links to review best practices in WooCommerce skip cache rules... putting this here, because it probably doesn't need a separate issue:

Ref: EasyEngine/easyengine#621
Ref: https://gist.github.com/pelmered/616efcde63c17a4dc3cd
Ref: https://spinupwp.com/wordpress-static-site-nginx-page-caching/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants