Viktor Bijlenga

NGINX cache based on cookies

I’ve been trying to let the NGINX fast-CGI cache serve different versions of a site, depending on a cookie value.

I want to use the cache, in this case, not skip it. If you want to skip the cache by cookie, read the excellent guide on caching by Deliocious Brains in their Ubuntu server guide.

To be able to serve different pages, I needed to update thefastcgi_cache_key directive. The directive is located in the /etc/nginx/sites-available/SITENAME/server folder, in a file named FastCGI-cache.conf when using SpinupWP.

You need to update it like this, I’ve keept the original line as a comment.

# The key to use when saving cache files, which will run through the MD5 hashing algorithm.
# fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_key "$scheme$request_method$host$request_uri$cookie_YOUR_COOKIE_NAME";

You can access cookie values in NGINX by using the $cookie_YOUR_COOKIE_NAME variable – a list of available NGINX variables can be found in the Nginx documentation.

This results in an NGINX cache which is different depending on the cookie value. This can be used to serve a dark theme and a light theme according to users’ preferences in a cookie, or different content security policies.

NOTE: This might create a lot of cached pages, which might result in a large number of files. Use with a bit of caution on larger sites.

NOTE 2: if you spot any errors, or have suggestions on how to improve further, please let me know.

Twenty Six

For the last years, I’ve written a post about the things I’ve learned so far. I’ve turned twenty six, which means it’s time for the post about twenty five things I’ve thought about. One thing for each year up to this point. The last year has been the hardest year of my life, it’s been a rollercoaster.

  • I’ve been reminded of the basics: Eat, sleep, repeat.
  • Love is never easy, but it’s always worth it. I learned a lot.
  • Postcards is underrated. Send more analog things.
  • The secret to relationships is talking to each other, no matter what.
  • Sparkling water is still my favorite beverage.
  • I missed the sun a lot during the winter.
  • Show up, put in the work, consistently.
  • Listen to more rock music classics. It’s always good.
  • Good design equals to good writing.
  • I enjoy travel by train more than I thought.
  • I’ve fallen in love. She is great.
  • Read more, a tiny bit every day is a good way to learn.
  • I don’t know what life is about, but I enjoy it a lot.
  • If you can find what you love and do that for a living, then you re beyond rich.
  • Work is never more important than anything else. Things can wait.
  • James Bay was my most played artist during the year. See him live.
  • Try to write more consistently. Make it easy. Write for yourself.
  • Live music is good for the soul.
  • Slow is great. Remember that.
  • Staring the day with listing to the news is a good way to get a headstart.
  • “En kvart I taget” (one quarter at a time) is a good reminder during hard times.
  • Calm company. I’ m good at running my own business. I’m happy.
  • The key to remote work is spending time together with people I love.
  • A good solid foundation is key to slow long-term happiness.
  • Notetomyself: Try to add love to everything you do.

Twenty Four

It’s my birthday (Jan 23), so it’s time to sit down and write the yearly summary of things I’ve thought and learned during the year. I’m turning 25 this year, which feels like a major milestone. Check out the other lists Tjugotvå (In swedish) and Twenty three. Those are my twenty four things.

  • Enjoy the Moment.
  • Always take the stairs.
  • Eating good makes life easier and better. Embrace your possibilities.
  • You laughed at Alex och Sigges podcast a lot during the year.
  • The basics are still important. Eat, sleep, repeat.
  • Be patient and work hard. Things take time.
  • Don’t use your phone while eating together with people. Be present.
  • Less complaining. Choose your bathroom sink battles wisly.
  • You stopped checking email before bed. Less stress. Great.
  • Vintersaga is a great song.
  • Watching Casey Neistats daily vlog has been a good time.
  • The Penny board (mini skateboard) is a great way to add fun to the equation of transportation between A / B.
  • The Grand Budapest Hotel is a great movie. Watch it again.
  • Take better photos. Buy a camera with a good lens. You miss it.
  • Write more.
  • Oscar Linnros was your most played artist on Spotify.
  • Learn more languages. It might be fun.
  • A good name for a brand is incredibly hard to come up with.
  • The news is not a source for happy-go-lucky. But a great way to excel at På Spåret next year.
  • When learning new languages, learn the fundamentals. It makes troubleshooting so much easier.
  • Building a company is a commitment. Remember that during hard days.
  • Express your dreams more clear. It’s easier to make goals then.
  • Making everyday life easier for other people is easier than you think.
  • Patience.

I wish that the Tictail store email template would be improved

A few days back I tweeted a thought I had for a while:

@tictail I wish that the emails genererad from my store would mirror my brand, instead of the Tictail brand.— Viktor Bijlenga (@viktorbijlenga) 27 oktober 2014

A simple wish that my online shop solution of choice, Tictail – would consider to improve the email which is sent to the customer as a confirmation when something is shipped.

Current email template design

Emails currently look like down below, when something you bought is shipped from a store powered by Tictail.


I think that this design is good, but it’s too focused on Tictail. I wish that the store’s brand would be the focus, since the communication is between a store owner and a customer.

The reasoning behind this, according to Tictail – is to establish trust and reliability for shoppers around the world1, ensure safe and protected transactions through the platform2 and add the benefit of being part of a strong community of entrepreneurs3.

Okay, those reasons sounds healthy to me. I want to be able to trust the store/plattform and have the opportunities that comes with a large community of creative people that creates something they believe in.

So I tweeted Tictail again:

A bit later I got a reply + multiple people had joined in to the discussion at this point.

Why should I write in English?

This is a post for me, and it might be a good thing for you, too. It’s gonna be my place to go, when I get that feeling – why am I doing this writing thingy – in which I write in a foreign language. A post to remind me of why I should write in English. You can call it a manifest, or a just what it is – a good reminder of a few things.

It’s good practice to practice

English is not a native language for me. It’s harder than Swedish. It’s harder to find certain words or write those jokes. It will probably always be like that. But it will get easier, If I practice. It’s okay to struggle. Remember the beginning. You’ve come far.

More friends, more feedback

The world is getting more global every minute. Just look at your website analytics. People from all over the world has visited this site.

Keep on writing

Oh, you think it sucks today. Ok. Great. Just do something else for awhile. Take a step back. Just don’t quit. It’s not the language, it’s just one of these days. It’s maybe time for a shower to clear your mind.

Share your thoughts with other people

Contribute to the community (read: nice people of the internet). Give back. Someone might learn something, something might happen. It’s fun to be apart of something bigger, that’s not limited by knowing Swedish.

A work in progress

It’s hard to show up every day, and post new things. It’s actually been months since I last published something new on this site. It feels sad, since I really like it. So I better get back on track. It’s fun to have a log of things that I like, get inspired by or things that I create.

Weekly links

Facebook released a Newsroom based on WordPress. First time I’ve seen WordPress being used by Facebook.

Sketchcasts – Three to four screencasts a month, covering all about Sketch!

Guide to Facebook News Feed image sizes is a good resource for designers creating content, that will end up in the Facebook news feed.

17 minutes on The making of John Mayer’s Born & Raised artwork.

The Swedish type foundry Letters From Sweden released a beautiful typeface called Ferry inspired by the ferries in Stockholm.

I found a interesting workflow for writing iMessages with Alfred App.

A few Mac apps we think all moderately computer-savvy persons should be using – a good guide to some of my best productivity tricks.

I learned that it’s possible to create desktop applications with node-webkit if you’re familiar with html/css/js.

Weekly links

Composer paired with WordPress – Better Dependency Management In Team-Based WordPress Projects With Composer. Looks interesting.

Interview with Bryan Jones, creator of CodeKit by @seb_ekstrom

Atom, the Github code editor is growing it’s package library. The beta currently has a total package count of over 500 according to Atoms blog

Mike Montario is releasing a new book for A Book Apart during 2013. It’s called “You’re My Favorite Client“. I can’t wait.

Someone spent time making website about the new iOS 7.1 shiftkey.

1Password released updates this week. I love that app more than anything else on my computer.

Minimal viewport tag in iOS 7.1

Video by Chris Coyier. A Quick Useful Case for Sass Math and Mixins – Good introduction to math in Sass.

Twenty Three

Every year on my birthday I try to write some kind of list of the things I’ve thought of during the year. Those are my twenty three things.

  • Family is more important than anything else in life.
  • Be nice, it’s not so hard.
  • Offline is an alternative to always connected even if you work with computers.
  • Be patient
  • Very few things needs to get done right away.
  • Read books and blogs. 140 characters is not enough.
  • Write more.
  • Buy a camera during 2014 and start a project.
  • You just love her. You do.
  • Call people, since you think Facebook is boring at the moment.
  • Learning to be creative in the kitchen is a challenge you will have to work on for a long time.
  • Sherlock Season 3. That’s quality tv-writing.
  • About time was your favorite movie. Watch it again.
  • You miss your friends a lot somedays. It’s sucks.
  • You are just getting started.
  • Things changes and becomes better.
  • New things are challenging.
  • You enjoy having a dog at the office. It’s super cosy.
  • The new apartment is great.
  • You are stupid. It’s great.
  • Do more of the things that makes you happy.
  • Don’t make things.
  • Fika.

Last year: 22 (written in Swedish)

New Year’s Resolutions as a front end developer – with follow up from last year

Last year I actually wrote a few New Year’s resolutions. Unfortunately, I had not started writing the blog in English then, so for you who (yet) don’t read Swedish, here are those resolutions:

  • Write during 2013 – I would simply write in my blog during 2013.
  • Scratch your own itch – Develop your own stuff, imagine solutions to your own problems.
  • Explain the difference – Learn other people more about how the web works.
  • Improve your process – Improve how I work on a daily basis.
  • Explore languages – learn more about PHP and Javascript.

So how did I do? What’s this year’s New Year’s resolutions?


I’m very happy with what I’ve accomplished in 2013 on the blog. The game changer has been to begin writing in English, which is still a major difference for me. It’s still exciting to look around at the statistics and see that people from different parts of the world has been visiting the site.

As usual Shawn Blanc has some good advice which I would like to remind myself of:

An article doesn’t always have to be published the moment after you’ve written the last paragraph.

Scratch your own itch

In 2013, I worked with a faster pace than ever before, especially during the fall. Thus, many of my own projects has suffered in some way. I have to set more realistic limits, or ship earlier.

Explain the difference

I not really know how to evaluate this. Actually, I should ask my girlfriend, because I’ve probably talked to much about work. For a while she taught me a thing about dancing every day, and I her one code-thingy. It was fun.

I like to teach, and in some sense I see my writing as a way for others to learn from my thoughts.

Improve your process

I moved all my development to git. I can’t even explain my process before git. Everything is suddenly much easier and smoother. It’s like 1Password, I can’t imagine my workdays without it.

I bought a standing desk. Got tired of sitting down all day. I feel better, and I have more energy when I’m not at work.

Explore languages

Learned a lot more about PHP and Javascript/jQuery during this year. The best way to tackle this for me, is to find real situations/problems where I can learn more by simply trying.

Thank God for SASS, saved me so much time, and made CSS even more fun.

What about 2014?

My new goal is to continue to work with those things I enjoy doing, because at the end of the day it’s the only thing that matters.

Do more of the things that makes you happy, Viktor.

Writing a Blog Is Hard

It’s hard to write a blog. Especially since I have decided that I have to write everything in English. It’s actually extremely hard for me, since I always feel that my vocabulary is limited.

Every now and then I’m reminded that it is indeed just that it’s all about. To write little every day, in order to get better. It works just like everything else. I need to practice.

Freelance thoughts

Sometimes I need to take a step back and admit to myself that I have achieved great things during the past months.

One of the projects that I’ve been working on during the last months feels great. It’s been a challenge on many levels to build.

Great work done by me.

Feels good to say that loud. You should try it too.

How to hide the WordPress update message in a git production enviroment

Since I use git on a lot of my projects, I don’t want to update WordPress in the production environment. So I wrote a few lines of code, that hides the update message. Add it to functions.php if you want to use it.

If you find some issues, or have some great ideas on how to improve it, just fork the gist.

How I feel about making the switch to write in English

A few weeks back I had a short, but still very interesting discussion with my colleague Li. We talked about Twitter, and the impact that it had on our network of people which we talk to, do business with, get inspired by and so on.

As usual (when talking to someone about Twitter) I told her about that I always thought of switching to English instead if Swedish. After a few minutes I was convinced that I finally should make the switch.

I’ve previous made the switch of language and every time I’ve felt silly. This time I convinced myself that I need to give it time. I need to be patient and slowly build new relations with people around the world.

I also decided that I had to switch my blog/site to English too, since this is the main place for sharing/thinking about stuff I care about. I want to contribute to the conversation, with my own words and thoughts.

It’s hard. I still feel silly and like a newbie. But I feel that is gonna be worth the struggle. My writing in English will get better, I hopefully will learn to know more great people and it will probably change things in more ways I can think of.

A few weeks back Federico Viticci posted I tweet that I constantly have in the back of my mind these days:

I need to remember that learning new things takes time, it’s a process. I write and share because that I’m interested in learning more. It will get easier, and I’ll probably feel less silly over time. I have to commit. I have to show up, practice and feel frustrated, solve problems, look up things. Just like when I write code or design something. Just like life.

I checked the stats for the blog for the first time since making the switch yesterday. That got me inspired to write this post. Suddenly there is activity from all over the world, not just Sweden. Someone on the other side of the world visited this blog. That’s magic.

Hello World, I’m Viktor. Say hi to me on @viktorbijlenga.

Responsibilty Email Design


Fler och fler människor läser sin mail i sin mobil, på en iPad eller via datorn. Det ställer nya krav på hur vi designar våra utskick. Det är vårt ansvar att se till att även nyhetsbrev tar steget in i framtiden.

Responsive Web Design kan vara ett sätt att möta dessa förändringar som just ju pågår med vår inbox, men jag tror inte det är det fullständiga svaret på problemet.

Därför har jag börjat tänka på hur jag själv skulle vilja att det vara. Dessutom har jag hittat på ett begrepp för det, som jag brukar använda när jag funderar kring dessa frågor.

Responsibilty Email Design

  • Responsibility – Ta ansvar för vad du skickar. Ingen gillar skit.
  • Responsive – Fokusera på upplevelsen = skapa bra och flexibelt innehåll för dina plattformar.
  • Respons – Utvärdera ständigt och förbättra i lagom takt. Tänk feedback.

Tre enkla punkter, som jag tror skulle förbättra många utskick som görs via email.

Responsibility – Ansvar är viktigt

Låt varje person välja själv om de vill ha ett nyhetsbrev. Använd inte någons adress bara för att den finns i något system. Var transparent och öppen. Låt de som vill ha mail, få dem. Opt-in, inte opt-out.

Det finns få saker som är lika tröttsamt som att avregistrera sig från nyhetsbrev som man inte vill få. Och du, se till att det är förbannat enkelt. Ingen blir glad av att krångla.

Responsive – Varför optimera för nya enheter?


Campaign Monitor:

If you send email newsletters, it’s likely that a growing percentage of your subscribers are reading your messages on an iPhone, tablet or similar. When we last surveyed email client popularity in 2011, we found that almost 20% of email opens occurred on a mobile device, rising dramatically from a mere 4% of the market when we last ran the numbers in 2009. iOS devices accounted for over 90% of these reported opens.

Små skärmar blir allt viktigare, även när det kommer till email. Fortfarande är det alldeles för många utskick som ser ut som skit när man öppnar de på en liten skärm.

Design är viktigt och en svår utmaning

Det här är en svår punkt att ge råd kring, eftersom jag upplever det som en utmaning att få allting att fungera som man vill. Alla webbdesigners som har designat ett nyhetsbrev vet hur krångligt det är. HTML-markup och stöd för CSS är lite bristfälligt. Fortsätt designa innehåll och koda, så löser det sig.

Tips på läsning:

Respons – Hur börjar jag?

Fundera igenom vilka nyhetsbrev du gillar. Lär dig av deras metoder, och börja diskutera hur era utskick kan bli bättre.

Att lära sig att göra vackra utskick är inte lätt. Det kräver tid, kunskap och en hel del experimenterande.

Nyhetsbrevet Pleasecopyme som Mattias Åkerberg gör inspirerar mig mycket, trots att det är analogt. Han har en skön ton, dessutom lyckas han ta betalt för det. Inspiration behöver inte bara inhämtas från samma medium. Lär dig av dina hjältar.

Tjänsterna Mailchimp och Campaign Monitor jobbar ständigt med att bli bättre. Följ med i deras processer. Tyvärr har jag alldeles för dålig koll på svenska alternativ som är i klass med dessa när det kommer till funktionalitet/prismodell.

Jag prövar just nu själv alla olika idéer jag kan på I’m With Friends utskick. Det är långt ifrån en fantastisk upplevelse, men sakta men säkert hoppas jag på skapa en bättre upplevelse för de som prenumererar. Vi skickar ungefär 1-2 nyhetsbrev i månaden.


  • Förutsättningarna förändras snabbt. Håll dig uppdaterad och alert.
  • Design hjälper till att göra information tillgänglig, även i email.
  • Ta ansvar för din kommunikation. Allt är marknadsföring.

Mer läsning

Om du har tankar, idéer eller kommentarer så pratar jag gärna med dig på Twitter. Där kan du även följa mig.@viktorbijlenga

Ikonerna i inlägget kommer från Entypo.

← Prev