Showing posts with label beginners. Show all posts
Showing posts with label beginners. Show all posts

Thursday, 21 November 2019

HTTP Caching Headers

I recently wanted to add some rather aggressive caching, to prevent my server getting hit too often.

Naturally, I wanted this caching to take place on the client, i.e. the webbrowser.

So, there have traditionally been advantages and disadvantages to caching.

Advantage: the server doesn't get hit again, and your website feels more responsive.

Disadvantage: it is possible to see outdated cached data.

Invalidating cache entries is basically an entire study of its own.

In my case I took the obvious route: the data stays the same forever.

This facilitates my caching wonderfully.

response.addHeader("Cache-Control","private, max-age=31536000");

This stores the item in the cache for one year (31536000 seconds).

Private means caching in the client browser, public means that it might also be elligible for caching in all other intermediaries between de browser and the server.

The blogs in the references are very clear.

References

[1] Heroku Dev Center - Increasing Application Performance with HTTP Cache Headers
https://devcenter.heroku.com/articles/increasing-application-performance-with-http-cache-headers
MDN Webdocs - HttpHeaders - Cache Control
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
MDN Webdocs - HTTP caching
https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching

Thursday, 31 January 2019

Git Branches

Just a little something for me to remember how to create branches and how to switch over to them.

There are plenty of resources available explaining how to do this, so I just thought I'd write some references down here.

$ git branch testing
creates a new branch called testing. Notice that this does not automatically make your new branch the current HEAD.
$ git log --oneline --decorate
seeing the branches in your log (as well as tags and the origins. Nice.)
54718edb (HEAD -> master, tag: v2.0.0, origin/master, origin/HEAD, v2.0.1) /* notes here. */
4c8c3bb9 /* moved the entire karchanangular into karchanpersonal. It compiles into the webapp directory. */
bb4bb432 /* upgrade from angular 4 to angular 7 */
12b528ed /* removed old directories that are no longer in use. Clean up. */
ead93fc3 /* changed images table, now has an autogenerated ID, plus an index on the pair owner and url. */
$ git checkout testing
switching to a branch
$ git checkout -b testing
shorthand for both creating a new branch called testing and checking it out immediately.
$ git checkout master ; git merge testing
merges the changes in the testing branch over into the master.
$ git checkout testing ; git merge master
merge the changes from your master into your testing branch.
$ git branch -d testing
delete a branch
$ git status
also shows you what branch you are on.
$ git show-branch
shows you all existing branches, and the commit that goes with that point in which it was branched.

References

GitBook - Git Branching
https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell
Git - Branch Manpage
https://git-scm.com/docs/git-branch
TutorialsPoint - Git Managing Branches
https://www.tutorialspoint.com/git/git_managing_branches.htm

Thursday, 6 April 2017

Try Git

To anyone who is absolutely new to the exciting new world of Git1.

There seems to be a little website where you can try Git2, working in a (very very) limited sandbox environment.

What is Git?

If you wish to know what Git is, there are loads of interesting articles on teh interwebs that explain it very well.

But I did find the following explanation in the README provided with the source tar-ball:
The name "git" was given by Linus Torvalds when he wrote the very
first version. He described the tool as "the stupid content tracker"
and the name as (depending on your mood):

 - random three-letter combination that is pronounceable, and not
   actually used by any common UNIX command.  The fact that it is a
   mispronunciation of "get" may or may not be relevant.
 - stupid. contemptible and despicable. simple. Take your pick from the
   dictionary of slang.
 - "global information tracker": you're in a good mood, and it actually
   works for you. Angels sing, and a light suddenly fills the room.
 - "goddamn idiotic truckload of sh*t": when it breaks

References

[1] Git --distributed-is-the-new-centralized
https://git-scm.com/
[2] Try Git
https://try.github.io/