Would it be beneficial to learn computer science (or other computer related stuff) from 5-6 year old material?
For many things it is possible, even advantageous, to learn from older books and materials. But it also depends on your goals. Computer Science, like any field, has some things that are fundamental and the fundamentals change only very slowly. The major programming paradigms, for example, were all created in the previous century. The fundamentals of compiling programs haven't changed in a long time. 

Also, while some areas have shiny-bright new stuff, a beginning student isn't going to study those first, but only after gaining some background in things that haven't changed in a long time. 

So, if you are a student, seeking a broad understanding of the field, then older materials won't be a handicap, though at some point you will want/need to learn the newer bells and whistles. 

But if you have a specific need, such as learning some specific technology at the expense of other things, then you should probably go with recent materials, even knowing that some of the details you learn will, themselves, change in a few years. 

Even networking has a lot of fundamental ideas that need to be understood before you can grasp the details of the latest networking protocols. 

Let me give an example. Recent versions of Java have introduced "exciting" new capabilities, including function abstraction. The beginning student won't study those things at the beginning, however, but will be more concerned with creating good OO programs. If you study Java from older materials, but also study something of functional programming (say Scheme or Haskell), also from old books, the new features of Java won't be a surprise to you. On the other hand, if you are faced with an eventual exam (such as the Advanced Placement CS-A) exam, then you need to study from materials that will prepare you for the questions that will be on that exam - likely newer books. 

But in general, many of the older books are true classics that will give you a deep understanding of fundamental things that make it possible for you to move easily into new things as they are introduced. Learn what is important. It is even enlightening to adapt old ideas, such as top-down-program-decomposition, to newer frameworks and to understand why things change. But that also requires background in the fundamentals.

Since you also mention online courses, you should note that a course from a few years ago is almost certainly still relevant. This is partly due to the fact that the creators of such courses are generally highly skilled and also value the newest ideas. It is very likely that the courses were very current at the time of creation, as well as being grounded in fundamental knowledge.  

As a final note, it is also sadly true that some of the older books have not been updated and the key, deep, ideas in them are not readily available elsewhere. The newer books may not incorporate the ideas of the older books so you may even lose something by only learning from the latest materials. I have one example of a book that had a truly excellent first edition (a Java textbook). The second edition, however, left out many of the parts that made the first so excellent, however. This is due to the unfortunate practice of book publishers to emphasize new editions whether they are an improvement over the old or not.