There are a lot of questions on this, so I'm not sure if my adding yet another answer is of much value, but I figure if there are a bunch that haven't been marked duplicates, there's room for another take. :)
Here's how I often describe these two tenses to my students, in case any of these comparisons help. (P.S. None of them are absolute, just generalizations!)
Basics
The passé composé is used to talk about a particular moment. You could ask what time or what day it happened — there's some individual unit, be it a a second, an hour, or a day, that corresponds to the action, like a doctor writing time of birth or death in her notebook.
The imparfait is used to talk about a span of time. You could ask when it started and stopped. It could be something you were in the middle of doing, something you used to do regularly, or a way you felt over the course of a day.
Did or was doing?
The passé composé is often translated "-ed".
J'ai marché, tu as parlé, et on a mangé de la crème glacée.
I walked, you talked, and we ate ice cream.
The imparfait is often translated "was... -ing".
Je marchais, tu parlais, et on mangeait de la crème glacée.
I was walking, you were talking, and we were eating ice cream.
One exception is that English often uses a simple past for emotional states even though French prefers the imparfait :
Il se sentait un peu triste.
He felt a little sad. (Or: He was feeling a little sad.)
And especially for the verbs avoir and être :
Elle avait trois frères.
She had three brothers.
Nous étions en détresse.
We were in distress.
More on this below with your "be absent" example. :)
Move on or dwell on?
The passé composé is when you want to mention the action and move on.
We ate ice cream that day, remember? You got a brain freeze and said you'd never eat ice cream again.
On a mangé de la crème glacée ce jour-là, tu t'en souviens ? Tu as eu le cerveau gelé et tu as dit que tu ne mangerais plus jamais de crème glacée.
The imparfait is when you want to dwell in the action and say what happened in the middle of it.
You were eating your ice cream when we suddenly heard a shout.
Tu mangeais ta crème glacée quand on a soudain entendu un cri.
Similarly, "while" pendant que is a great clue that the imparfait is appropriate. Then the other half of the sentence, the thing that happens during the action, is in passé composé.
While you were showering, your mother called.
Pendant que tu te douchais, ta mère a appelé/téléphoné.
Finished or not?
The passé composé is for something that got finished.
They fixed the roof.
Ils ont réparé le toit.
The imparfait is for something that got interrupted.
They were fixing the roof, but it started to rain.
Ils réparaient le toit, mais il a commencé à pleuvoir.
This sense is also very similar to être en train de :
They were fixing the roof, but it started to rain.
Ils étaient en train de réparer le toit, mais il a commencé à pleuvoir.
Became or continued to be?
Charles I took the throne of England in 1625. He was in power until his execution in 1649.
Charles I est monté sur le trône anglais en 1625. Il était au pouvoir jusqu'à son exécution en 1649.
"I was absent"
The subtle cases are when the verb describes a state: "be absent" or any other adjective. Something that's naturally a period of time no matter how you frame it. Then they become nearly interchangeable.
Do you want to say you were absent; the fact is established; you don't need to dwell on particular events during the absence?
I was absent for two days back in March. I was sick.
J'ai été absent deux jours là, en mars. J'ai été/J'étais malade.
- You could replace "I was absent for two days" with "I missed two days" j'ai manqué deux jours and have the exact same meaning and perspective on the fact.
Or do you want to say that you were absent, and pause there for a second because something else happened at the same time?
Yes, you did give the instructions for the homework, but I was absent and missed them.
Oui, vous avez bien donné les consignes pour le devoir, mais j'étais absent et je les ai manquées.
- You could replace "I was absent" with "I wasn't there" je n'étais pas là and have the exact same meaning and perspective on the fact.
But I don't think anyone would find it too strange if you used the other tense in either case.
Appendix: Still true in the present or not?
It's worth taking up @Maxence1402's useful answer, although I don't cover this when first introducing the imparfait.
Both the imparfait and the passé composé are past tenses, but the latter is technically called "present perfect". It can still have an effect on the present, because of how avoir is conjugated.
Here's the usual way to translate a passé composé verb:
J'ai enseigné toute ma vie.
I taught all my life.
But it could also have this next meaning, which new students tend to use more than they should because it makes so much sense when going one word at a time:
J'ai enseigné toute ma vie.
I've taught all my life.
In the first translation, the speaker no longer teaches. But in the second one, they still teach!
The relevance for your question is that you could say J'ai été absent and depending on the context, it could still be true now. You might not have returned yet. But if you say J'étais absent, you're definitely back by now.
This might be confusing because it sounds like the opposite of the "Finished or not?" point from earlier. I would say this is a separate meaning of the passé composé.